Skip to content

qiu8310/jsonfy

Repository files navigation

jsonfy

NPM version Build Status Dependency Status Coverage Status Code Climate

Parse json like string to json object

Install

$ npm install --save jsonfy

Usage

var jsonfy = require('jsonfy');
jsonfy('12')                  // result number: 12
jsonfy('"12"')                // result string: '12'
jsonfy('[a, 2.5, true]')      // result array : ['a', 2.5, true] 
jsonfy('{a: a b c, f: 2e2}')  // result object: {a: 'a b c', f: 200}

jsonfy('{str: abc, bool: true, number: 0.24, array: [1,2], emptyObj: {}}');
// return object: {str: 'abc', bool: true, number: 0.24, array: [1, 2], emptyObj: {}}

Feature

  • Fully compatible with JSON string
  • String can use single quote
  • String don't need quote only if it is a number string or it contains characters ],},' or "

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using gulp.

License

Copyright (c) 2015 Zhonglei Qiu. Licensed under the MIT license.

About

Parse simple string to json object

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published