in JSLib/src/odata-json-light.js [1233:1277]
var formatJsonLightProperty = function (name, value, pMetadata, data) {
/// <summary>Formats an object's value identified by name to its json light representation and saves it to data.</summary>
/// <param name="name" type="String">Property name.</param>
/// <param name="value">Property value.</param>
/// <param name="pMetadata" type="Object">Object that contains metadata for the property that is being formatted.</param>
/// <param name="data" type="Object">Object on which the formatted value is going to be stored.</param>
// Get property type from property metadata
var propertyMetadata = pMetadata && pMetadata[name] || { properties: undefined, type: undefined };
var typeName = dataItemTypeName(value, propertyMetadata);
if (isPrimitive(value) || !value) {
// It is a primitive value then.
formatJsonLightAnnotation(typeAnnotation, name, typeName, data);
data[name] = value;
return;
}
if (isFeed(value, typeName) || isEntry(value)) {
formatJsonLightInlineProperty(name, value, data);
return;
}
if (!typeName && isDeferred(value)) {
// It is really a deferred property.
formatJsonLightDeferredProperty(name, value, data);
return;
}
if (isCollection(value, typeName)) {
// The thing is a collection, format it as one.
if (getCollectionType(typeName)) {
formatJsonLightAnnotation(typeAnnotation, name, typeName, data);
}
formatJsonLightCollectionProperty(name, value, data);
return;
}
djsassert(isComplex(value), "formatJsonLightProperty - Value is not a complex type value");
// Format the complex property value in a new object in data[name].
data[name] = {};
formatJsonLightAnnotation(typeAnnotation, null, typeName, data[name]);
formatJsonLightData(value, propertyMetadata.properties, data[name]);
};