json-parse-language
v1.0.3
Published
For parsing the complex json
Downloads
2
Readme
JSON Parse Language
For parsing the complex json in a simple way by specing it.
Guide
const transformObject = require(".");
transformObject(data,spec)
For accessing a key you can put @ For example
{
name: "@profile.name"
}
For concatenating
{
name: "@profile.name + @profile.address"
}
{
name: "@profile.name + 'is good'"
}
For array operations
{
name: "@profile.marks[*].mark"
}
Example
const complexJSON={
name: "Govind",
progressCard: {
marks: [{
subject: "Mathematics",
mark: 49,
outOf: 50
},
{
subject: "Physics",
mark: 40,
outOf: 50
},],
age: 29
}
}
const specJSON = {
name: "@name",
totalMarksReceived:"@progressCard.marks[*].mark",
totalMarks:"@progressCard.marks[*].outOf",
note: "@name+' is good at mathematics'"
}
// Output Will be
{
name: "Govind",
totalMarksReceived: 89,
totalMarks: 100,
note: "Govind is good at mathematics"
}