Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
0Activity
0 of .
Results for:
No results containing your search query
P. 1
Json Light at a Glance

Json Light at a Glance

Ratings: (0)|Views: 9|Likes:
Published by markdstafford

More info:

Published by: markdstafford on Apr 17, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

04/17/2012

pdf

text

original

 
JSON Light At A Glance March 31, 2012
1 |
Page
 
JSON Light at a Glance
 
Contents
Motivation ..................................................................................................................................................... 2JSON Light Design .......................................................................................................................................... 2Response payload samples ........................................................................................................................... 3Entry .......................................................................................................................................................... 3Feed ........................................................................................................................................................... 4Property ..................................................................................................................................................... 4Entry with expanded navigation links ....................................................................................................... 5Service document ...................................................................................................................................... 5Entity reference links ................................................................................................................................. 6Top-level (streaming) collections .............................................................................................................. 6Error ........................................................................................................................................................... 7Request payload samples .............................................................................................................................. 7Entry .......................................................................................................................................................... 7Entry with deep inserts.............................................................................................................................. 8Entry with binding operations (insert or update)...................................................................................... 8Property ..................................................................................................................................................... 9Entity reference links ................................................................................................................................. 9Parameters ................................................................................................................................................ 9The metadata URL ....................................................................................................................................... 10Annotations ................................................................................................................................................. 12What annotations are used for ............................................................................................................... 12Annotation Groups .................................................................................................................................. 13Controlling the amount of control information in the payload .................................................................. 15$metadata=default .................................................................................................................................. 15$metadata=none ..................................................................................................................................... 15$metadata=all .......................................................................................................................................... 15Content Type and Payload Ordering Constraints ........................................................................................ 17Metadata Expressions ................................................................................................................................. 18CSDL Annotations .................................................................................................................................... 18OData Metadata Expressions .................................................................................................................. 18Metadata Expression Composition Rules ................................................................................................ 20Combinator Functions ............................................................................................................................. 21Functions in Metadata Expressions ......................................................................................................... 22Conclusion ................................................................................................................................................... 23
 
JSON Light At A Glance March 31, 2012
2 |
Page
 
Motivation
OData/WCF Data Services currently supports a JSON format that has a couple of problems. The two thatinspired the design of JSON Light are:
 
Payload size: the current JSON format is too verbose on the wire thus unnecessarily increasing
the payload size of a response. As a result we now refer to the existing JSON format also as ‘JSONverbose’.
 
 
Ease-of-use for JScript/jQuery processors: JSON verbose has a set of wrapper objects (especiallyaround collections) that make the format hard to use in JScript/jQuery since these wrapperswere sprinkled in between the actual data. As a result extracting the actual data (without anycontrol information) as JSON involved stripping out all such wrappers and, for a set of clients,made it harder to access the data than it should be.
Disclaimer: this document represents preliminary thinking about a light-weight JSON format for OData.Not all aspects of this new format have been locked down yet and in particular the names and constantsare likely to change.
JSON Light Design
A few requirements guided the development of the JSON Light format; the most important ones arelisted below as a frame of reference but are not discussed in detail.
 
The payload size should be minimized while preserving all the information present in the currentATOM and JSON verbose formats.
 
The response payloads should be easy to consume in pure JScript or jQuery processors.
 
The format should intrinsically support extensibility for future versions of OData.
 
The format should support streaming (e.g., for endless feeds) with the assumption that only asingle entry ever fits into memory.
 
Clients should be able to control the trade-off between payload size on the wire andcomputational requirements on the client.
 
The system should be fully functional with no out-of-band information in clients.
 
Feedback from the OData/REST community should continuously influence the format to get thebroadest possible support for JSON Light.The approach we took to accomplish the above is as follows: in order to make the new format easy toprocess by JScript/jQuery clients, we have to continue to use a JSON representation on the wire (asopposed to a binary representation for example). Looking at the current JSON (verbose) payloads, largeparts of the payload are highly stylized (for example, the edit links for all the entries in a feed might onlydiffer in the value of the key property of the entry but otherwise be identical). To minimize the payloadsize, all the stylized pieces in the payload were removed from the actual wire format. Instead,expressions to compute the stylized payload parts were added in annotations to the metadata
 
JSON Light At A Glance March 31, 2012
3 |
Page
 
document. These metadata expressions (together with the data on the wire) can be used by the client tore-compute all the stylized payload pieces as if they would have been on the wire directly.The extensibility story of the new JSON Light format revolves around so-called annotations in thepayload. Annotations are used to non-intrusively add control information to a JSON Light payload. Suchannotations can refer to a JSON object or a JSON property and provide additional information about theinstance (or property). OData defines a set of annotations and custom annotations can be addingdomain-specific control information to the payload.In JSON Light, annotations are used to capture control information that cannot be expressed viametadata expressions (e.g., the next link of a feed) as well as to provide a mechanism to override thevalues that would otherwise be computed from the expressions (e.g., if the stream read link of oneparticular entry points to a different server than the metadata expression for all the other entriesspecifies). Computing values from metadata expressions is compute intensive and some clients mightchoose a larger payload size over the necessity to compute expressions; as a result the new $metadataquery option allows the client to control whether or not control information should be embedded intothe payload or will be computed from expressions.To make JSON Light payloads support streaming scenarios, we put in place a few restrictions withrespect to order in which data must appear on the wire. More details are discussed in
C
T
 Payload Ordering Constraints. The community is engaged via a shared repository for the JSON Light spec on GitHub and via variousOData distribution and mailing lists.
Response payload samples
This section provides JSON Light samples of response payloads for all the payload kinds supported inOData based on sample data from the Northwind database.
Entry
{"odata.metadata": "http://northwind.odata.org/$metadata#NorthwindModel.NorthwindEntities/Customers/@Element""CustomerID": "ALFKI","CompanyName": "Alfreds Futterkiste","ContactName": "Maria Anders","ContactTitle": "Sales Representative","Address": "Obere Str. 57","City": "Berlin"}
Comments:
 

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->