[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xml to json converter
On Fri, Sep 17, 2021 at 7:40 PM Liam R. E. Quin <liam@fromoldbooks.org> wrote: You might want to compare it to the JSON support built in to XQuery and Ok. I shall look into this, as I would further explore this topic. Also test content containing [ ] " { } " ' I couldn't test with XML element names and content, containing ആൺകുട്ടി for example. Which language is this please? The other parts I've tested, and it works fine with the same technical pattern that I've described within my original mail on this thread. Below are further details, that I've tested newly. The XSD document is, <?xml version="1.0" encoding="ISO-8859-1"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="X"> <xs:complexType> <xs:sequence> <xs:element name="ARÊT" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="b" type="xs:string" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute name="id" type="xs:integer"/> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> And the corresponding, XML instance document is, <?xml version="1.0" encoding="ISO-8859-1"?> <X> <ARÊT id="1"> <b>hello</b> <b>world ARÊT</b> </ARÊT> <ARÊT id="2"> <b>I'm</b> <b>[ ] " { } " ' & < > \ /</b> </ARÊT> </X> Please note following, a) I now need to specify encoding="ISO-8859-1" within XSD and XML instance documents. b) As suggested by you, I've specified the text containing [ ] " { } " ' & < > \ and / within XML instance document, encoded as entity references required for XML documents. The JAXB command xjc, generated file X.java needs following custom change to handle this test case, public class X { @XmlElement(name = "AR\u00caT", required = true) @JsonProperty("AR\u00caT") // we need to add this annotation, for jackson to circumvent default java beans naming convention protected List<X.ARÊT> arêt; Running the same java program, that I've posted earlier within this thread, now produces following JSON result, { "ARÊT" : [ { "b" : [ "hello", "world ARÊT" ], "id" : 1 }, { "b" : [ "I'm", "[ ] \" { } \" ' & < > \\ /" ], "id" : 2 } ] } (I think, jackson JSON serializer correctly escapes special characters) Regards, Mukul Gandhi
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] |
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|