Convert XML to JSON format

后端 未结 10 885
粉色の甜心
粉色の甜心 2020-12-13 07:43

I have to convert docx file format (which is in openXML format) into JSON format. I need some guidelines to do it. Thanks in advance.

10条回答
  •  被撕碎了的回忆
    2020-12-13 07:47

    The XML class in the org.json namespace provides you with this functionality.

    You have to call the static toJSONObject method

    Converts a well-formed (but not necessarily valid) XML string into a JSONObject. Some information may be lost in this transformation because JSON is a data format and XML is a document format. XML uses elements, attributes, and content text, while JSON uses unordered collections of name/value pairs and arrays of values. JSON does not does not like to distinguish between elements and attributes. Sequences of similar elements are represented as JSONArrays. Content text may be placed in a "content" member. Comments, prologs, DTDs, and <[ [ ]]> are ignored.

提交回复
热议问题