How would I express XML tag attributes in JSON?

后端 未结 13 2234
遥遥无期
遥遥无期 2020-12-07 20:35

I am designing an API for my webapp.

I was thinking to support only JSON responses (not XML) because more streamlined.

But I have just bumped to this XML:

13条回答
  •  广开言路
    2020-12-07 21:16

    There is a JSON notation / convention called badgerfish attempts to standardizes (at least its own terms) the way of preserving of most of the low level XML semantics when XML DOM represented as JSON DOM (with attributes of course) (see http://badgerfish.ning.com/).

    So you can easily convert back the badgerfishied-json representation to the XML representation and you still work on the structure with your favorite XML toolset (for me its XPATH / QUERY expressions and tools).

    It has also easy to memorize syntax rules (total 9) like: "Attributes go in properties whose names begin with @". You can work on badgerfishied-json in the text editor without overloading your neural circuitry unnecessarily. Usually you can memorize them in the first pass.

提交回复
热议问题