dist/jsonapi.js
function deserialize(json) {
        var data, deserialized;

        var includedMap = {};
        each(json.included, function(value) {
            var key = value.type + '-' + value.id;
            includedMap[key] = value;
        });

        if (isArray(json.data)) {
            data = map(
                json.data,
                function(record) {
                    populateRelatedFields(record, includedMap);
                    return flatten(record);
                }
            );
        }
        else if (isObject(json.data)) {
            populateRelatedFields(json.data, includedMap);
            data = flatten(json.data);
        }

        deserialized = {
            data: data,
            jsonapi: json.jsonapi || {}
        };

        if (json.meta) {
            deserialized.meta = json.meta;
        }

        if (json.errors) {
            deserialized.errors = json.errors;
        }

        if (json.links) {
            deserialized.links = json.links;
        }

        return deserialized;
    }
function deserialize(json) {
        var data, deserialized;

        var includedMap = {};
        each(json.included, function(value) {
            var key = value.type + '-' + value.id;
            includedMap[key] = value;
        });

        if (isArray(json.data)) {
            data = map(
                json.data,
                function(record) {
                    populateRelatedFields(record, includedMap);
                    return flatten(record);
                }
            );
        }
        else if (isObject(json.data)) {
            populateRelatedFields(json.data, includedMap);
            data = flatten(json.data);
        }

        deserialized = {
            data: data,
            jsonapi: json.jsonapi || {}
        };

        if (json.meta) {
            deserialized.meta = json.meta;
        }

        if (json.errors) {
            deserialized.errors = json.errors;
        }

        if (json.links) {
            deserialized.links = json.links;
        }

        return deserialized;
    }
function deserialize ( json ) { var data , deserialized ; var includedMap = { } ; each ( json . included , function ( value ) { var key = value . type + '-' + value . id ; includedMap [ key ] = value ; } ) ; if ( isArray ( json . data ) ) { data = map ( json . data , function ( record ) { populateRelatedFields ( record , includedMap ) ; return flatten ( record ) ; } ) ; } else if ( isObject ( json . data ) ) { populateRelatedFields ( json . data , includedMap ) ; data = flatten ( json . data ) ; } deserialized = { data : data , jsonapi : json . jsonapi || { } } ; if ( json . meta ) { deserialized . meta = json . meta ; } if ( json . errors ) { deserialized . errors = json . errors ; } if ( json . links ) { deserialized . links = json . links ; } return deserialized ; }
Deserialize the JSONAPI formatted object
Deserialize the JSONAPI formatted object