How to use json8 - 2 common examples

To help you get started, we’ve selected a few json8 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sonnyp / JSON8 / packages / patch / lib / operations.js View on Github external
'use strict'

var JSON8Pointer = require('json8-pointer')
var parse = JSON8Pointer.parse
var walk = JSON8Pointer.walk
var JSON8 = require('json8')
var clone = JSON8.clone
var equal = JSON8.equal
var get = require('./extras').get

/**
 * Add the value to the specified JSON Pointer location
 * http://tools.ietf.org/html/rfc6902#section-4.1
 *
 * @param  {Object|Array} doc    - JSON document to set the value to
 * @param  {Path}         path   - JSON Pointer string or tokens path
 * @param  {Any}          value  - value to add
 * @return {Array}               - [document, replaced value]
 */
var add = function(doc, path, value) {
  var tokens = parse(path)

  // replaces the document
github sonnyp / JSON8 / packages / patch / lib / operations.js View on Github external
'use strict'

var JSON8Pointer = require('json8-pointer')
var parse = JSON8Pointer.parse
var walk = JSON8Pointer.walk
var JSON8 = require('json8')
var clone = JSON8.clone
var equal = JSON8.equal
var get = require('./extras').get

/**
 * Add the value to the specified JSON Pointer location
 * http://tools.ietf.org/html/rfc6902#section-4.1
 *
 * @param  {Object|Array} doc    - JSON document to set the value to
 * @param  {Path}         path   - JSON Pointer string or tokens path
 * @param  {Any}          value  - value to add
 * @return {Array}               - [document, replaced value]
 */
var add = function(doc, path, value) {
  var tokens = parse(path)

  // replaces the document
  if (tokens.length === 0)

json8

JSON toolkit for JavaScript

ISC
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular json8 functions