I need help parsing this XML message into a JSON structure. I have tried using Jackson library using XmlMapper
. It keeps giving a parsing error. Do I need to parse out extra characters?
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<ns2:GetLineItemDetailResponse xmlns:ns2="http://schema.tmt.com/transactionlineitemdetail/loyalty/v1">
<GetLineItemDetailResult>
<Coupons>
<Coupon>
<CouponType>sim_default_CouponType</CouponType>
<CouponNumber>sim_default_CouponNumber</CouponNumber>
<LineNumber>0</LineNumber>
<Amount>0</Amount>
</Coupon>
</Coupons>
<Tenders>
<Tender>
<TenderCode>sim_default_TenderCode</TenderCode>
<Amount>0</Amount>
<RedemptionID>0</RedemptionID>
</Tender>
</Tenders>
<LineItems>
<LineItem>
<LineNumber>0</LineNumber>
<Type>1</Type>
<Quantity>0</Quantity>
<TotalTax>0</TotalTax>
<UPC>sim_default_UPC</UPC>
<UnitPrice>0</UnitPrice>
<ExtendedPrice>0</ExtendedPrice>
<TotalPrice>0</TotalPrice>
<OriginalRFN xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<OriginalOrderID xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<IneligForRedeem>false</IneligForRedeem>
<RX>
<Days>0</Days>
<ThirtyTo90>false</ThirtyTo90>
<GovtFunded>1970-01-01T00:00:00</GovtFunded>
<RXType>NEW</RXType>
<PartialFill>false</PartialFill>
<ImmunInd>false</ImmunInd>
<ImmunType>sim_default_ImmunType</ImmunType>
<RXEligibleInd>false</RXEligibleInd>
</RX>
<ns3:UPCDescription xmlns:ns3="http://www.epsilon.com/webservices/">sim_default_UPCDescription</ns3:UPCDescription>
</LineItem>
</LineItems>
<Redemption>
<AwardID>0</AwardID>
<Amount>0</Amount>
<Points>0</Points>
</Redemption>
</GetLineItemDetailResult>
</ns2:GetLineItemDetailResponse>
I have tried this:
XmlMapper xmlMapper = new XmlMapper();
JsonNode node = xmlMapper.readTree(xml.getBytes());
ObjectMapper jsonMapper = new ObjectMapper();
String json = jsonMapper.writeValueAsString(node);
System.out.println(json);
But keep getting error
Misshaped close tag at 2299 [character 91 line 52]