All Downloads are FREE. Search and download functionalities are using the official Maven repository.

prompto.reader.JSONReader.js Maven / Gradle / Ivy

There is a newer version: 0.1.57
Show newest version
function jsonRead(text) {
    var node = JSON.parse(text);
    return toValue(node);
}

function toValue(node) {
    if (node === null)
        return null;
    else if (Array.isArray(node))
        return toList(node);
    else if (typeof(node) === "object")
        return toDocument(node);
    else
        return node;
}

function toList(node) {
    var values = node.map(toValue);
    return new intrinsic.List(false, values);
}


function toDocument(node) {
    var doc = new intrinsic.Document();
    for(var name in node) {
        if(node.hasOwnProperty(name))
            doc[name] = toValue(node[name]);
    }
    return doc;
}

exports.jsonRead = jsonRead;




© 2015 - 2024 Weber Informatics LLC | Privacy Policy