JSON Response unordered - new semantics?

Dan Kamins's Avatar

Dan Kamins

17 May, 2011 03:54 AM

The semantics of a customer XML include that e.g. the first subscription listed is the current active one.

However when outputting JSON (such as from PHP's library's "toJson()"), the hash/dicts such as subscriptions (whose keys are subscription IDs) no longer have guaranteed ordering, as JSON does not support ordering of dicts.

How can we determine with a JSON output which subscription is the active one?

What other ordering-dependent aspects of the customer data will we need to find another way of determining?

  1. Support Staff 1 Posted by Marc Guyer on 17 May, 2011 04:00 PM

    Marc Guyer's Avatar

    However when outputting JSON (such as from PHP's library's "toJson()"), the hash/dicts such as subscriptions (whose keys are subscription IDs) no longer have guaranteed ordering, as JSON does not support ordering of dicts.

    Interesting. I didn't know that.

    How can we determine with a JSON output which subscription is the active one?

    The subscription with the latest createdDatetime is the current active subscription.

    What other ordering-dependent aspects of the customer data will we need to find another way of determining?

    Probably invoices. Those are ordered by billingDatetime.

    I know you guys aren't exclusively using the PHP wrapper but in there are convenience methods for getting the current subscription, current invoice, etc. Those methods return arrays but if you need json, you can reencode it after getting the desired item.

  2. Dean closed this discussion on 16 Jan, 2013 05:15 PM.

Discussions are closed to public comments.
If you need help with Cheddar please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

28 Mar, 2024 10:45 PM
24 Jan, 2024 08:33 AM
11 Jan, 2024 07:13 AM
30 Nov, 2023 02:07 AM
22 Nov, 2023 08:41 AM