Skip to content

Commit

Permalink
Merge pull request #106 from bomrafinha/bomrafinha
Browse files Browse the repository at this point in the history
Ajuste de conversão JSON -> XML
  • Loading branch information
bomrafinha authored Dec 6, 2020
2 parents de2f62b + 97db089 commit b980991
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<br />

![Maintenance](https://img.shields.io/maintenance/yes/2020)
![Build](https://img.shields.io/badge/Build-1.2.30.477-brightgreen)
![Build](https://img.shields.io/badge/Build-1.2.30.479-brightgreen)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/bomrafinha/FormatConverter)
![GitHub Release Date](https://img.shields.io/github/release-date/bomrafinha/FormatConverter)
![Github repo age](https://img.shields.io/github/issues/detail/age/bomrafinha/FormatConverter/1.svg?style=flat-square)
Expand Down
41 changes: 37 additions & 4 deletions modules/JSONtoXML/U_JSON.XML.pas
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ TJSONtoXML = class(
function tabular(nivel : integer) : String;
function getAtributosStr(nodos : IXMLNodeList) : string;
function typeText(json : String) : string;
function checksBlockEnclosure(xmlStr : String) : string;

public
function stringToString(strContent : String) : String;
Expand Down Expand Up @@ -46,6 +47,36 @@ implementation

{ TJSONtoXML }

function TJSONtoXML.checksBlockEnclosure(xmlStr: String): string;
var
aux: string;

begin
Result := xmlStr;

aux :=
StringReplace(
Copy(
xmlStr,
1,
Pos(
'>',
xmlStr
)
),
'<',
'</',
[rfReplaceAll, rfIgnoreCase]
);

Result := IfThen(
(pos(aux, xmlStr) + aux.Length) >= (xmlStr.Length),
xmlStr,
'<xml>' + xmlStr + '</xml>'
);

end;

function TJSONtoXML.fileToFile(filePath, filePathResult: String): Boolean;
var
arquivo : TStringList;
Expand Down Expand Up @@ -592,10 +623,12 @@ function TJSONtoXML.originTypeToReturnType(content: TJSONObject): TXMLDocument;
aux : String;

begin
xmlStr := Trim(
Self.nodeToXMLStr(
TJSONArray(content),
aux
xmlStr := Self.checksBlockEnclosure(
Trim(
Self.nodeToXMLStr(
TJSONArray(content),
aux
)
)
);

Expand Down
29 changes: 29 additions & 0 deletions project/CSVtoXML.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,26 @@
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Linux64' and '$(Base)'=='true') or '$(Base_Linux64)'!=''">
<Base_Linux64>true</Base_Linux64>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='OSX32' and '$(Base)'=='true') or '$(Base_OSX32)'!=''">
<Base_OSX32>true</Base_OSX32>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
<Base_Win32>true</Base_Win32>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Base)'=='true') or '$(Base_Win64)'!=''">
<Base_Win64>true</Base_Win64>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
<Cfg_1>true</Cfg_1>
<CfgParent>Base</CfgParent>
Expand Down Expand Up @@ -75,22 +90,36 @@
<PropertyGroup Condition="'$(Base_Android)'!=''">
<DCC_CBuilderOutput>None</DCC_CBuilderOutput>
<EnabledSysJars>android-support-v4.dex.jar;cloud-messaging.dex.jar;fmx.dex.jar;google-analytics-v2.dex.jar;google-play-billing.dex.jar;google-play-licensing.dex.jar;google-play-services-ads-7.0.0.dex.jar;google-play-services-analytics-7.0.0.dex.jar;google-play-services-base-7.0.0.dex.jar;google-play-services-identity-7.0.0.dex.jar;google-play-services-maps-7.0.0.dex.jar;google-play-services-panorama-7.0.0.dex.jar;google-play-services-plus-7.0.0.dex.jar;google-play-services-wallet-7.0.0.dex.jar</EnabledSysJars>
<DCC_UsePackage>rtl;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_iOSDevice32)'!=''">
<DCC_CBuilderOutput>None</DCC_CBuilderOutput>
<DCC_UsePackage>rtl;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_iOSDevice64)'!=''">
<DCC_CBuilderOutput>None</DCC_CBuilderOutput>
<DCC_UsePackage>rtl;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_iOSSimulator)'!=''">
<DCC_CBuilderOutput>None</DCC_CBuilderOutput>
<DCC_UsePackage>rtl;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Linux64)'!=''">
<DCC_UsePackage>rtl;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_OSX32)'!=''">
<DCC_UsePackage>rtl;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''">
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
<BT_BuildType>Debug</BT_BuildType>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<VerInfo_Locale>1033</VerInfo_Locale>
<DCC_UsePackage>rtl;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win64)'!=''">
<DCC_UsePackage>rtl;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1)'!=''">
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
Expand Down
9 changes: 3 additions & 6 deletions project/FormatConverter.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
<DCC_RemoteDebug>false</DCC_RemoteDebug>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Keys>CompanyName=Ridge Dynamics;FileDescription=$(MSBuildProjectName);FileVersion=1.2.30.477;InternalName=Format Convert;LegalCopyright=;LegalTrademarks=;OriginalFilename=FormatConvert;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<VerInfo_Build>477</VerInfo_Build>
<VerInfo_Keys>CompanyName=Ridge Dynamics;FileDescription=$(MSBuildProjectName);FileVersion=1.2.30.479;InternalName=Format Convert;LegalCopyright=;LegalTrademarks=;OriginalFilename=FormatConvert;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<VerInfo_Build>479</VerInfo_Build>
<VerInfo_MinorVer>2</VerInfo_MinorVer>
<VerInfo_Release>30</VerInfo_Release>
<VerInfo_AutoIncVersion>true</VerInfo_AutoIncVersion>
Expand Down Expand Up @@ -178,10 +178,7 @@
<Source>
<Source Name="MainSource">FormatConverter.dpk</Source>
</Source>
<Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k250.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dclofficexp250.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
</Excluded_Packages>
<Excluded_Packages/>
</Delphi.Personality>
<Deployment Version="3">
<DeployFile LocalName="$(BDS)\Redist\osx32\libcgunwind.1.0.dylib" Class="DependencyModule">
Expand Down
12 changes: 6 additions & 6 deletions project/FormatConverterTester.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,6 @@
</Excluded_Packages>
</Delphi.Personality>
<Deployment Version="3">
<DeployFile LocalName="..\app\FormatConverterTester.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>FormatConverterTester.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\Redist\osx32\libcgunwind.1.0.dylib" Class="DependencyModule">
<Platform Name="OSX32">
<Overwrite>true</Overwrite>
Expand All @@ -383,6 +377,12 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="..\app\FormatConverterTester.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>FormatConverterTester.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libPCRE.dylib" Class="DependencyModule">
<Platform Name="iOSSimulator">
<Overwrite>true</Overwrite>
Expand Down
44 changes: 22 additions & 22 deletions project/Format_Converter.groupproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
<Projects Include="CSVtoXML.dproj">
<Dependencies/>
</Projects>
<Projects Include="JSONtoCSV.dproj">
<Dependencies/>
</Projects>
<Projects Include="JSONtoXML.dproj">
<Dependencies/>
</Projects>
<Projects Include="XMLtoCSV.dproj">
<Projects Include="JSONtoCSV.dproj">
<Dependencies/>
</Projects>
<Projects Include="XMLtoJSON.dproj">
<Dependencies/>
</Projects>
<Projects Include="XMLtoCSV.dproj">
<Dependencies/>
</Projects>
<Projects Include="FormatConverter.dproj">
<Dependencies/>
</Projects>
Expand Down Expand Up @@ -65,15 +65,6 @@
<Target Name="CSVtoXML:Make">
<MSBuild Projects="CSVtoXML.dproj" Targets="Make"/>
</Target>
<Target Name="JSONtoCSV">
<MSBuild Projects="JSONtoCSV.dproj"/>
</Target>
<Target Name="JSONtoCSV:Clean">
<MSBuild Projects="JSONtoCSV.dproj" Targets="Clean"/>
</Target>
<Target Name="JSONtoCSV:Make">
<MSBuild Projects="JSONtoCSV.dproj" Targets="Make"/>
</Target>
<Target Name="JSONtoXML">
<MSBuild Projects="JSONtoXML.dproj"/>
</Target>
Expand All @@ -83,14 +74,14 @@
<Target Name="JSONtoXML:Make">
<MSBuild Projects="JSONtoXML.dproj" Targets="Make"/>
</Target>
<Target Name="XMLtoCSV">
<MSBuild Projects="XMLtoCSV.dproj"/>
<Target Name="JSONtoCSV">
<MSBuild Projects="JSONtoCSV.dproj"/>
</Target>
<Target Name="XMLtoCSV:Clean">
<MSBuild Projects="XMLtoCSV.dproj" Targets="Clean"/>
<Target Name="JSONtoCSV:Clean">
<MSBuild Projects="JSONtoCSV.dproj" Targets="Clean"/>
</Target>
<Target Name="XMLtoCSV:Make">
<MSBuild Projects="XMLtoCSV.dproj" Targets="Make"/>
<Target Name="JSONtoCSV:Make">
<MSBuild Projects="JSONtoCSV.dproj" Targets="Make"/>
</Target>
<Target Name="XMLtoJSON">
<MSBuild Projects="XMLtoJSON.dproj"/>
Expand All @@ -101,6 +92,15 @@
<Target Name="XMLtoJSON:Make">
<MSBuild Projects="XMLtoJSON.dproj" Targets="Make"/>
</Target>
<Target Name="XMLtoCSV">
<MSBuild Projects="XMLtoCSV.dproj"/>
</Target>
<Target Name="XMLtoCSV:Clean">
<MSBuild Projects="XMLtoCSV.dproj" Targets="Clean"/>
</Target>
<Target Name="XMLtoCSV:Make">
<MSBuild Projects="XMLtoCSV.dproj" Targets="Make"/>
</Target>
<Target Name="FormatConverter">
<MSBuild Projects="FormatConverter.dproj"/>
</Target>
Expand All @@ -120,13 +120,13 @@
<MSBuild Projects="FormatConverterTester.dproj" Targets="Make"/>
</Target>
<Target Name="Build">
<CallTarget Targets="Padronizacao;CSVtoJSON;CSVtoXML;JSONtoCSV;JSONtoXML;XMLtoCSV;XMLtoJSON;FormatConverter;FormatConverterTester"/>
<CallTarget Targets="Padronizacao;CSVtoJSON;CSVtoXML;JSONtoXML;JSONtoCSV;XMLtoJSON;XMLtoCSV;FormatConverter;FormatConverterTester"/>
</Target>
<Target Name="Clean">
<CallTarget Targets="Padronizacao:Clean;CSVtoJSON:Clean;CSVtoXML:Clean;JSONtoCSV:Clean;JSONtoXML:Clean;XMLtoCSV:Clean;XMLtoJSON:Clean;FormatConverter:Clean;FormatConverterTester:Clean"/>
<CallTarget Targets="Padronizacao:Clean;CSVtoJSON:Clean;CSVtoXML:Clean;JSONtoXML:Clean;JSONtoCSV:Clean;XMLtoJSON:Clean;XMLtoCSV:Clean;FormatConverter:Clean;FormatConverterTester:Clean"/>
</Target>
<Target Name="Make">
<CallTarget Targets="Padronizacao:Make;CSVtoJSON:Make;CSVtoXML:Make;JSONtoCSV:Make;JSONtoXML:Make;XMLtoCSV:Make;XMLtoJSON:Make;FormatConverter:Make;FormatConverterTester:Make"/>
<CallTarget Targets="Padronizacao:Make;CSVtoJSON:Make;CSVtoXML:Make;JSONtoXML:Make;JSONtoCSV:Make;XMLtoJSON:Make;XMLtoCSV:Make;FormatConverter:Make;FormatConverterTester:Make"/>
</Target>
<Import Project="$(BDS)\Bin\CodeGear.Group.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Group.Targets')"/>
</Project>
29 changes: 29 additions & 0 deletions project/XMLtoJSON.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,26 @@
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Linux64' and '$(Base)'=='true') or '$(Base_Linux64)'!=''">
<Base_Linux64>true</Base_Linux64>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='OSX32' and '$(Base)'=='true') or '$(Base_OSX32)'!=''">
<Base_OSX32>true</Base_OSX32>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
<Base_Win32>true</Base_Win32>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Base)'=='true') or '$(Base_Win64)'!=''">
<Base_Win64>true</Base_Win64>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
<Cfg_1>true</Cfg_1>
<CfgParent>Base</CfgParent>
Expand Down Expand Up @@ -75,22 +90,36 @@
<PropertyGroup Condition="'$(Base_Android)'!=''">
<DCC_CBuilderOutput>None</DCC_CBuilderOutput>
<EnabledSysJars>android-support-v4.dex.jar;cloud-messaging.dex.jar;fmx.dex.jar;google-analytics-v2.dex.jar;google-play-billing.dex.jar;google-play-licensing.dex.jar;google-play-services-ads-7.0.0.dex.jar;google-play-services-analytics-7.0.0.dex.jar;google-play-services-base-7.0.0.dex.jar;google-play-services-identity-7.0.0.dex.jar;google-play-services-maps-7.0.0.dex.jar;google-play-services-panorama-7.0.0.dex.jar;google-play-services-plus-7.0.0.dex.jar;google-play-services-wallet-7.0.0.dex.jar</EnabledSysJars>
<DCC_UsePackage>xmlrtl;rtl;fmx;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_iOSDevice32)'!=''">
<DCC_CBuilderOutput>None</DCC_CBuilderOutput>
<DCC_UsePackage>xmlrtl;rtl;fmx;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_iOSDevice64)'!=''">
<DCC_CBuilderOutput>None</DCC_CBuilderOutput>
<DCC_UsePackage>xmlrtl;rtl;fmx;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_iOSSimulator)'!=''">
<DCC_CBuilderOutput>None</DCC_CBuilderOutput>
<DCC_UsePackage>xmlrtl;rtl;fmx;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Linux64)'!=''">
<DCC_UsePackage>xmlrtl;rtl;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_OSX32)'!=''">
<DCC_UsePackage>xmlrtl;rtl;fmx;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''">
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
<BT_BuildType>Debug</BT_BuildType>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<VerInfo_Locale>1033</VerInfo_Locale>
<DCC_UsePackage>xmlrtl;rtl;fmx;Padronizacao;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win64)'!=''">
<DCC_UsePackage>xmlrtl;rtl;fmx;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1)'!=''">
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
Expand Down

0 comments on commit b980991

Please sign in to comment.