I need to parse a custom .json file like this:
{"04 Device Name " :
{
"ECU_1":
{
"01 Diagnostic" : "OK",
"02 CAN Id" : "123456789"
,
"01 SoftwareVersion " : {
"01 DID" : "123456789",
"02 Value " : "123456789"
}
,
"02 HardwareVersion " : {
"01 DID" : "123456789",
"02 Value " : "123456789"
}
}
}
into a custom .xml like this
<Component>
<ECUShortName>ECU_1</ECUShortName>
<LocationShortName>ECU_1_1</LocationShortName>
<LocationAccessKey>[Protocol]UDS_CAN_D.[EcuBaseVariant]BC_F213.[EcuVariant]123456789</LocationAccessKey>
<DiagnosticInfo>
<DiagnosticInfoValue>123456789</DiagnosticInfoValue>
</DiagnosticInfo>
<CommunicationProtocol>UDS</CommunicationProtocol>
<CommunicationState>8</CommunicationState>
<DTCCount>
<DTCCountValue>4</DTCCountValue>
</DTCCount>
<SWHWInformation>
<Software>
<PartNumber>
<PartNumberValue>123456789</PartNumberValue>
</PartNumber>
<Version>
<VersionValue>17/38/00</VersionValue>
</Version>
<Category>2</Category>
<Supplier>
<Code>1234</Code>
<Name>Supplier_1</Name>
</Supplier>
</Software>
<Hardware>
<PartNumber>
<PartNumberValue>123456789</PartNumberValue>
</PartNumber>
<Version>
<VersionValue>15/44/01</VersionValue>
</Version>
<Supplier>
<Code>1234</Code>
<Name>Supplier_1</Name>
</Supplier>
</Hardware>
</SWHWInformation>
I could use almost any language, but cant think of one that suits best. VisualBasic would be good for XML, JS for JSON. But it isn't correctly formatted in JSON...
Do you have any idea, how this could be done?
XSLT 3.0 is pretty good for this. You can just write an XML-style template and populate it with values drawn from the JSON:
etc.
That's only a sketch, of course, because you've only provided a sketch of your actual data.