xsl-list
[Top] [All Lists]

Re: [xsl] Recovering the 'document order' of parsed json

2013-10-29 07:23:58
On 10/28/2013 09:05 PM, Liam R E Quin wrote:
On Mon, 2013-10-28 at 20:11 -0500, David Cramer wrote:

I'm experimenting with parse-json and the map functions, but I gather
that once parse-json gives me a map, I have no way of recovering the
original order of the keys in the source json.

In general JSON maps are not ordered:

{ "a" : 1,
  "socks" : "black" }
is the same as
{ "socks" : "black",
  "a" : 1 }
...
Hope this helps - if not, maybe send some short/simple test cases?

Hi Liam,
I had a feeling someone would say that...

Sure it's true that json maps are not ordered, but for documentation
purposes it is often helpful to present items in a logical order.
Consider the code sample in:

https://github.com/rackerlabs/otter/blob/master/docbook/src/docbkx/samples/reqCreatePolicy-changePercentAlarm.json

When you make the api call, it doesn't matter what order you list name,
changePercent, cooldown, type, and args, but for the purposes of
documenting the request, starting with "name" will look a lot more
natural and logical than starting with "args".

Regards,
David


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--