简体   繁体   中英

Converting XML to JSON using GSON in PI Java Mapping

["

I am facing issue while converting the source xml into JSON using the GSON library.<\/i>

<data>
<ERP>0080001</ERP>
<Shiptoparty>0088000</Shiptoparty>
<Shippingpoint>503</Shippingpoint>
<Issuedate>20181102</Issuedate>
<products>
<Unit>L</Unit>
<QTY>2.000 </QTY>
<SKUno>000000000011</SKUno>
</products>
<products>
<Unit>L</Unit>
<QTY>0.000 </QTY>
<SKUno>000000000011000078</SKUno>
</products>
</data>

I think you have problem with encoding. Possible solution is

String jsonString = new Gson().toJson(objectToEncode);
byte[] utf8JsonString = jsonString.getBytes("UTF8");
responseToClient.write(utf8JsonString, 0, utf8JsonString.Length);

I hope this will work for you :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM