-
Initialize your project as a Node project.
$ npm init -yNote:
-yskips all of the prompts. -
Install Accio.
$ npm install @drashland/accio -
Create your
data.jsonfile. You can copy theexample_data.jsonfile from this repository. -
Create your
app.jsfile.const { accio } = require("@drashland/accio"); const { readFileSync } = require("fs"); const data = readFileSync("./data.json", "utf-8"); const result = accio(data) .array("versions") // Target the array named "versions" .findOne({ // In the array, find one object that has a name field ... name: "v0.0.3", // ... with the value of "v0.0.3" }) .array("release_notes") // In the object, target the array named "release_notes" .findOne({ // In the array, find one object that has a title field ... title: "Bug Fixes", // ... with the value of "Bug Fixes" }) .array("body") // In the object, target the array named "body" .first() // Target the first object in the array .get(); // Finally, get the item console.log(result.type); console.log(result.text);
-
Run your
app.jsfile.$ node app.jsYou should see the following:
bullet Fix issue with date objects not being correctly validated.