在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:jsonicjs/jsonic开源软件地址:https://github.com/jsonicjs/jsonic开源编程语言:JavaScript 95.8%开源软件介绍:jsonicA JSON parser for Node.js that isn't strict.A JSON parser that can parse "bad" JSON. Mostly, this is about avoiding the need to quote everything! Strict JSON requires you to do this: { "foo":"bar", "red":1 } The JavaScript language itself is a little easier: { foo:"bar", red:1, } But if you really want to be lazy, jsonic lets you say: foo:bar, red:1, See below for the relaxed JSON rules. This module is used by the Seneca framework to provide an abbreviated command syntax. SupportIf you're using this module, feel free to contact me on twitter if you have any questions! :) @rjrodger Quick examplevar jsonic = require('jsonic')
// parse a string into a JavaScript object
var obj = jsonic('foo:1, bar:zed')
// prints { foo: 1, bar: 'zed' }
console.dir( obj ) Installnpm install jsonic Relaxed RulesJSONIC format is just standard JSON, with a few rule relaxations:
StringifyThe jsonic module provides a console.log( jsonic.stringify( {a:"bc",d:1} ) ) // prints {a:bc,d:1} The
For example, you can limit the depth of the object tree printed: console.log( jsonic.stringify( {a:{b:{c:1}}}, {depth:2} ) ) // prints {a:{b:{}}} NOTE: The options are:
How it WorksThe parser uses PEG.js and is an extension of the example JSON parser included in that project. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论