An Interesting JSON Example

In web services development folks use JSON all the time. However, the JSON format itself is very interesting, in terms of the wide range of semantics (e.g. classes lists, dicts etc) it can represent

Recent I spent some time understanding the format itself.

Example 1:

{“Unixtimestamp”:14593556,”Entities”:[{“Id”:”eid1″},{“Id”:”math”},{“Id”:”computerscience”}],”CategoricalEntries”:[{“Name”:”course”,”Value”:”math”},{“Name”:”major”,”Value”:”computerscience”}],”NumericalEntries”:[{“Name”:”durationspentinmilliseconds”,”Value”:40.0}],”GeoLocations”:[{“Name”:”location”,”Latitude”:”0.34.5N”,”Longitude”:”3.456S”}]}

Example 2:

{“Unixtimestamp”:14593556,”Value”:100.0,”Entities”:{“userid”:”eid1″,”courseid”:”math”,”majorid”:”computerscience”},”CategoricalEntries”:{“course”:”math”,”major”:”computerscience”},”NumericalEntries”:{“durationspentinmilliseconds”:40.0},”GeoLocations”:[{“Latitude”:”0.34.5N”,”Longitude”:”3.456S”}]}

Notice how the “CategoricalEntries” section actually represents different semantics –

  • Example1 : “CategoricalEntries” represents list of objects. The object has two properties explicitly called “Name” and “Value”
  • Example2 : “CategoricalEntries” represents a Dictionary<string, string>

Code:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s