READ-XML / Write-JSON

Posted by xjg on 19-Sep-2017 05:56

Hello,

I'm working in a XML -> JSON transformation by automatically reading the XML file using the READ-XML method from the ProDataSet class.

The behavior that I'm trying to deal with is that all the fields appear to be converted to character, thus, all the fields written afterwards in the JSON file have their value quoted since they are all treated as characters although they are supposed to be decimal.

When I load the XML file to the ProDataSate I can Write the Schema generated when reading and I can see there that indeed all the xsd elements of the fields have the property "type="xsd:string".

I've tried to use the option field-type-mapping from the READ-XML method but I can't make my WRITE-JSON method to show any field as decimal nor this option seems to modify the schema written.

Does anybody know how could I do to get the fields with their correct type?

Thanks in advance for your answers!

Posted by Robin Brown on 19-Sep-2017 10:05

field-type-mapplng only applies when creating a dataset/temp-table definition based on an XML Schema. As Peter said, having a static definition with correct field types is the way to go if you don't want to use an XML Schema.

All Replies

Posted by Peter Judge on 19-Sep-2017 08:58

If the temp-table fields are all characters then the WRITE-JSON call will write strings.
 
It sounds like the READ-XML is not converting correctly.

Posted by xjg on 19-Sep-2017 09:21

Hi Peter,

Thanks for your answer.

That's my suspicion too but I would like to use the READ-XML method without passing to it an schema definition, everything in the process is working pretty good but this conversion..

I have a workaround for this situation but I would like to know if I was missing something and I could somehow define the type of the field for a given set of fields, that's why I tried the field-type-mapping option but including this parameter is not showing any change..

Posted by Peter Judge on 19-Sep-2017 09:36

Usually , if you have a static temp-table defined, the READ-XML will do the right thing.
 

Posted by Robin Brown on 19-Sep-2017 10:05

field-type-mapplng only applies when creating a dataset/temp-table definition based on an XML Schema. As Peter said, having a static definition with correct field types is the way to go if you don't want to use an XML Schema.

Posted by xjg on 19-Sep-2017 10:09

Hello Robin / Peter,

Thank you both for your answers!

This thread is closed