JSON Best Practice for Property Names -


is "best practice" use guid property name? (see sample json below)

{     "errortype": 0,     "i9e4f0477549111d997e0acd5cbb90d3f": {         "statuscode": "0",         "guid": "i9e4f0477549111d997e0acd5cbb90d3f",         "moreproperties": "more values"     },     "n51d209f0505711dea52dfad621371b7c": {         "statuscode": "0",         "guid": "n51d209f0505711dea52dfad621371b7c",         "moreproperties": "more values"     } } 

i assume no because isn't whole "object" part of json gone? no longer have access namespace because property name random. , serializing (using json.net) no longer one-liner.

furthermore there repeated data. guid name of property , within property object property name of "guid". data normalization not being considered.

i'm not writing json consuming it. if writing json rewrite this:

{     "errortype": 0,     "guids": [         {             "statuscode": "0",             "guid": "i9e4f0477549111d997e0acd5cbb90d3f",             "moreproperties": "more values"          },         {             "statuscode": "0",             "guid": "n51d209f0505711dea52dfad621371b7c",             "moreproperties": "more values"          }     ] } 

thoughts?

if you're searching objects guid in javascript, it's better use guid key, allowing write obj[someguid].

otherwise, depends on environment , usage; please provide more details.


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -