in lib/odata/json.js [273:333]
function addFullMetadataToJsonPayload(data, model, recognizeDates) {
var type;
if (utils.isObject(data)) {
for (var key in data) {
if (data.hasOwnProperty(key)) {
if (key.indexOf('@') === -1) {
if (utils.isArray(data[key])) {
for (var i = 0; i < data[key].length; ++i) {
addFullMetadataToJsonPayload(data[key][i], model, recognizeDates);
}
} else if (utils.isObject(data[key])) {
if (data[key] !== null) {
//don't step into geo.. objects
type = data[key+'@odata.type'];
if (!type) {
//type unknown
addFullMetadataToJsonPayload(data[key], model, recognizeDates);
} else {
type = type.substring(1);
if (isGeographyEdmType(type) || isGeometryEdmType(type)) {
// don't add type info for geo* types
} else {
addFullMetadataToJsonPayload(data[key], model, recognizeDates);
}
}
}
} else {
type = data[key + '@odata.type'];
// On .Net OData library, some basic EDM type is omitted, e.g. Edm.String, Edm.Int, and etc.
// For the full metadata payload, we need to full fill the @data.type for each property if it is missing.
// We do this is to help the OlingoJS consumers to easily get the type of each property.
if (!assigned(type)) {
// Guessing the "type" from the type of the value is not the right way here.
// To do: we need to get the type from metadata instead of guessing.
var typeFromObject = typeof data[key];
if (typeFromObject === 'string') {
addType(data, key, 'String');
} else if (typeFromObject === 'boolean') {
addType(data, key, 'Boolean');
} else if (typeFromObject === 'number') {
if (data[key] % 1 === 0) { // has fraction
addType(data, key, 'Int32'); // the biggst integer
} else {
addType(data, key, 'Decimal'); // the biggst float single,doulbe,decimal
}
}
}
else {
if (recognizeDates) {
convertDatesNoEdm(data, key, type.substring(1));
}
}
}
}
}
}
}
return data;
}