in lib/odata/json.js [96:121]
function jsonParser(handler, text, context) {
var recognizeDates = defined(context.recognizeDates, handler.recognizeDates);
var model = context.metadata;
var json = (typeof text === "string") ? JSON.parse(text) : text;
var metadataContentType;
if (assigned(context.contentType) && assigned(context.contentType.properties)) {
metadataContentType = context.contentType.properties["odata.metadata"]; //TODO convert to lower before comparism
}
var payloadFormat = getFormatKind(metadataContentType, 1); // none: 0, minimal: 1, full: 2
// No errors should be throw out if we could not parse the json payload, instead we should just return the original json object.
if (payloadFormat === 0) {
return json;
}
else if (payloadFormat === 1) {
return addMinimalMetadataToJsonPayload(json, model, recognizeDates);
}
else if (payloadFormat === 2) {
// to do: using the EDM Model to get the type of each property instead of just guessing.
return addFullMetadataToJsonPayload(json, model, recognizeDates);
}
else {
return json;
}
}