0

Which of the following JSON data formats is better as a server response for mobile apps and any graphing, tabular and repeater widgets that may display the data.

Format 1 Array of Arrays

{"Columns":["SETTLE_DATE","AMOUNT"],"Data":[["03/01/2011",365267.03],["03/02/2011",377867.03],["03/03/2011",390467.03],["03/07/2011",754067.03],["03/08/2011",766667.03],["03/09/2011",779267.03],["03/10/2011",793667.03],["03/11/2011",817067.03],["03/12/2011",1132067.03],["03/13/2011",1144667.03],["03/14/2011",1157267.03],["03/15/2011",1169867.03],["03/17/2011",1195067.03],["03/18/2011",1207667.03],["03/19/2011",1524467.03],["03/20/2011",1537067.03],["03/21/2011",1549667.03],["03/22/2011",1562267.03],["03/23/2011",1576667.03],["03/31/2011",10600.03]],"TotalCount":20}

Format 2 Array of Objects

{ Data: [ { “date”: “20110301”, “amt”: 36527.03}, { “date”: 20110301, “amt”: 36527.03}, { “date”: “20110301”, “amt”: 36527.03} ], “TotalCount”: 20 }

What are the pros/cons of one over another?

1 Answer 1

3

"Better" is subjective.

IMO objects are more communicative, to both humans and code (e.g., Android's GSON stuff). Otherwise you're unmarshaling untyped tuples, which is error-prone.

On the JS side, some client libraries just work better if you're dealing with named values, and again, it's more difficult to make non-obvious mistakes.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.