Skip to content

nicola/json-to-ldp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json-to-ldp

Navigate JSON in a Linked Data Platform fashion

Install

$ npm install json-to-ldp

Usage

This module exposes two apis:

toLDP(json, depth)

var toLdp = require('json-to-ldp')

var json = {
  people: [{
    name: "Nicola"
  }, {
    name: "Virginia"
  }]
}
toLDP(json)
/*
{
  contains: ["0", "1"]
}
*/

toLDP(json[0])
/*
{
  name: "Nicola"
}
*/

.traverse(data, path, depth)

var traverse = require('json-to-ldp').traverse

var json = {
  title: "Address book"
  people: [{
    name: "Nicola"
  }, {
    name: "Virginia"
  }]
}

traverse(json, '/people/')
/*
{
  title: "Address book"
  contains: ["0", "1"]
}
*/

traverse(json, '/people/0')
/*
{
  name: "Nicola"
}
*/

License

MIT

About

Navigate JSON in a Linked Data Platform fashion

Resources

License

Stars

Watchers

Forks

Packages

No packages published