bhall2001 / fastjson

A Livecode library for JSON encoding and decoding to and from Arrays.
MIT License
17 stars 11 forks source link

Possible update to consider #6

Closed madpink closed 8 years ago

madpink commented 8 years ago

Numeric keys may be desired, the keepNumeric parameter would override "isNumericalArray". (I've made this change in my own version of easyJson)

madpink commented 8 years ago

The following is an example of what the JSON would look like, downloaded from CouchDB.

In this example, the key "call" is a JSON object the consists of 4 keys (1,2,3,4) each with a JSON object as its value. The numeric keys are treated as strings.

For my purposes in this program, the number value is significant because it represents a specific order. Saving to JSON wouldn't be a problem, because the array that would be created would retain the order below. However, importing back into Livecode can (and most often does) change the sequence.

I honestly have no idea if this an issue other people would care about, obviously there are ways around this.

{ "_id": "x2714", "_rev": "20-2632e258f1da796869b9336eb8a2f66f", "fnord": { "notes": "9/25-VMNML", "attempts": 4, "lastintv": "test", "deadoralive": "alive", "quota": null, "queue": 4, "laststat": "Voice Mail", "laststatcode": 104 }, "call": { "1": { "timetocall": 1442601861, "status": "Voice Mail", "laststat": "Voice Mail", "notes": "9/18-LVM800", "timestamp": 1442590761, "lastintv": "test", "laststatcode": 104 }, "2": { "timetocall": 1442689900, "status": "Voice Mail", "laststat": "Voice Mail", "notes": "9/19-VMNML", "timestamp": 1442678800, "lastintv": "test", "laststatcode": 104 }, "3": { "timetocall": 1443206066, "status": "Voice Mail", "laststat": "Voice Mail", "notes": "9/25-VMNML", "timestamp": 1443194966, "lastintv": "test", "laststatcode": 104 }, "4": { "laststatcode": 104, "timestamp": 1443285344, "status": "Voice Mail", "laststat": "Voice Mail", "lastintv": "test", "timetocall": 1443296444 } } }

Below is what the output would look like without the keepNumeric param:

{ "_id": "x2714", "_rev": "20-2632e258f1da796869b9336eb8a2f66f", "fnord": { "notes": "9/25-VMNML", "attempts": 4, "lastintv": "test", "deadoralive": "alive", "quota": null, "queue": 4, "laststat": "Voice Mail", "laststatcode": 104 }, "call": [ { "timetocall": 1442601861, "status": "Voice Mail", "laststat": "Voice Mail", "notes": "9/18-LVM800", "timestamp": 1442590761, "lastintv": "test", "laststatcode": 104 }, { "timetocall": 1442689900, "status": "Voice Mail", "laststat": "Voice Mail", "notes": "9/19-VMNML", "timestamp": 1442678800, "lastintv": "test", "laststatcode": 104 }, { "timetocall": 1443206066, "status": "Voice Mail", "laststat": "Voice Mail", "notes": "9/25-VMNML", "timestamp": 1443194966, "lastintv": "test", "laststatcode": 104 }, { "laststatcode": 104, "timestamp": 1443285344, "status": "Voice Mail", "laststat": "Voice Mail", "lastintv": "test", "timetocall": 1443296444 } ] }