How to use the jju.parse function in jju

To help you get started, we’ve selected a few jju 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 microsoft / just / packages / just-scripts-utils / src / rush.ts View on Github external
export function _parseRushJson(rushJsonContents: string): RushJson | undefined {
  try {
    // rush.json can contain comments, so we have to use a json library which supports comments
    // (instead of JSON.parse/JSON.stringify)
    return jju.parse(rushJsonContents, { mode: 'cjson' });
  } catch {
    return undefined;
  }
}
github microsoft / rushstack / libraries / node-core-library / src / JsonFile.ts View on Github external
public static load(jsonFilename: string): any {
    // tslint:disable-line:no-any
    if (!FileSystem.exists(jsonFilename)) {
      throw new Error(`Input file not found: ${jsonFilename}`);
    }

    const contents: string = FileSystem.readFile(jsonFilename);
    try {
      return jju.parse(contents);
    } catch (error) {
      throw new Error(`Error reading "${jsonFilename}":` + os.EOL + `  ${error.message}`);
    }
  }
github microsoft / just / packages / just-scripts-utils / src / __tests__ / rush.spec.ts View on Github external
it('parses file', () => {
    const rushJsonParsed = jju.parse(rushJsonStr, { mode: 'cjson' });
    expect(_parseRushJson(rushJsonStr)).toEqual(rushJsonParsed);
  });
});
github OfficeDev / office-ui-fabric-react / scripts / read-config.js View on Github external
function readConfig(file) {
  file = findConfig(file);
  if (file && fs.existsSync(file)) {
    return jju.parse(fs.readFileSync(file, 'utf8'));
  }
}
github rlidwka / jju / editor.html View on Github external
function update_deps() {
   var items = $('#dependencies').val()
   if (items === _old_items) return
   _old_items = items
   
   var deps = {}
   var json = jju.parse($('textarea').val())
   $('#dependencies').tagsinput('items').forEach(function(x) {
    deps[x] = (json.dependencies && json.dependencies[x]) || '*'
   })
   on_input_update('dependencies', deps)
  }
 })()
github ds300 / react-native-typescript-transformer / index.js View on Github external
function loadJsonFile(jsonFileName) {
  try {
    const buffer = fs.readFileSync(jsonFileName)
    const jju = require('jju')
    return jju.parse(buffer.toString())
  } catch (error) {
    throw new Error(
      `Error reading "${jsonFileName}":${os.EOL}  ${error.message}`
    )
  }
}
github wiredmax / npm-json5 / lib / read.js View on Github external
'package.json5': function json2json(data) {
		var JSON5 = require('jju')
		return JSON.stringify(JSON5.parse(data.toString('utf8')))
	},
github coderaiser / cloudcmd / server / config.js View on Github external
const readjsonSync = (name) => {
    return jju.parse(fs.readFileSync(name, 'utf8'), {
        mode: 'json',
    });
};
github rlidwka / jju / editor.html View on Github external
function on_input_update(name, value) {
 var old_text = $('textarea').val()
 var json = jju.parse(old_text)
 
 if (value === '') {
  delete json[name]
 } else {
  json[name] = value
 }
 $('textarea').val(jju.update(old_text, json))
}
<a href="https://github.com/rlidwka/jju"><img class="forkme" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" src="https://github-camo.global.ssl.fastly.net/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67"></a><nav class="navbar navbar-default" role="navigation"><div class="container-fluid"><div class="collapse navbar-collapse"><ul class="nav navbar-nav"><li><a href="index.html">Home</a></li><li><a href="readme.html">Readme</a></li><li class="active"><a href="editor.html">Demo - Editor</a></li><li><a href="tokenizer.html">Demo - Tokenizer</a></li></ul></div></div></nav><div class="container"><div class="row"><div class="col-md-6"><form class="form-horizontal" role="form"><div class="form-group my-cool-editor"><label class="control-label col-sm-2" for="name">Name</label><div class="col-sm-10"><input class="form-control" placeholder="foobar" type="text"></div><label class="control-label col-sm-2" for="version">Version</label><div class="col-sm-10"><input class="form-control" placeholder="1.2.3" type="text" id="version"></div><label class="control-label col-sm-2" for="description">Desc</label><div class="col-sm-10"><input class="form-control" placeholder="module that hopefully does something useful" type="text" id="description"></div><label class="control-label col-sm-2" for="author">Author</label><div class="col-sm-10"><input class="form-control" placeholder="My Name <my@email>" type="text" id="author"></div><label class="control-label col-sm-2" for="dependencies">Deps</label><div class="col-sm-10"><input class="form-control" data-role="tagsinput" placeholder="" type="text" id="dependencies"></div></div></form><pre class="error">Warning: you really need JavaScript to be enabled to get it working</pre></div><div class="col-md-6"><form role="form"><div class="form-group"><div class="col-sm-12"><label class="control-label" for="textarea">Copy-paste your package.json here:</label></div><div class="col-sm-12"><textarea class="form-control" rows="20" id="textarea">{ "name": "just-a-demo",</textarea></div></div></form></div></div></div>

jju

a set of utilities to work with JSON / JSON5 documents

MIT
Latest version published 6 years ago

Package Health Score

67 / 100
Full package analysis