New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

neatjson

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

neatjson - npm Package Compare versions

Comparing version 0.8.3 to 0.10.0

lua/flickering-lane-graph.json

119

javascript/neatjson.js

@@ -19,18 +19,20 @@ (function(exports){

if (!('afterColonN' in opts)) opts.afterColonN = ('aroundColonN' in opts) ? opts.aroundColonN : ('afterColon' in opts) ? opts.afterColon : 0;
if (!('forceFloatsIn' in opts)) opts.forceFloatsIn = [];
var apad = repeat(' ',opts.arrayPadding),
opad = repeat(' ',opts.objectPadding),
comma = repeat(' ',opts.beforeComma)+','+repeat(' ',opts.afterComma),
colon1 = repeat(' ',opts.beforeColon1)+':'+repeat(' ',opts.afterColon1),
colonN = repeat(' ',opts.beforeColonN)+':'+repeat(' ',opts.afterColonN);
const apad = repeat(' ',opts.arrayPadding),
opad = repeat(' ',opts.objectPadding),
comma = repeat(' ',opts.beforeComma)+','+repeat(' ',opts.afterComma),
colon1 = repeat(' ',opts.beforeColon1)+':'+repeat(' ',opts.afterColon1),
colonN = repeat(' ',opts.beforeColonN)+':'+repeat(' ',opts.afterColonN);
var build = memoize();
return build(value,'');
const build = memoize();
return build(value,'',opts.forceFloats);
function memoize(){
var memo = new Map;
return function(o,indent){
var byIndent=memo.get(o);
if (!byIndent) memo.set(o,byIndent={});
if (!byIndent[indent]) byIndent[indent] = rawBuild(o,indent);
const memo = new Map;
return function(o,indent,floatsForced){
const byFloats = floatsForced ? {o,floatsForced} : o;
let byIndent=memo.get(byFloats);
if (!byIndent) memo.set(byFloats,byIndent={});
if (!byIndent[indent]) byIndent[indent] = rawBuild(o,indent,floatsForced);
return byIndent[indent];

@@ -40,16 +42,27 @@ }

function rawBuild(o,indent){
function rawBuild(o,indent,floatsForced){
if (o===null || o===undefined) return indent+'null';
else{
if (typeof o==='number'){
var isFloat = (o === +o && o !== (o|0));
return indent + ((isFloat && ('decimals' in opts)) ? o.toFixed(opts.decimals) : (o+''));
if (o===Infinity) {
return indent+'9e9999';
}else if (o===-Infinity){
return indent+'-9e9999';
}else if (Number.isNaN(o)){
return indent+'"NaN"';
}else{
const treatAsFloat = floatsForced || (o === +o && o !== (o|0));
let result = indent + ((treatAsFloat && ('decimals' in opts)) ? o.toFixed(opts.decimals) : (o+''));
if (opts.trimTrailingZeros) result = (+result)+'';
if (floatsForced && result.indexOf('.')==-1) result += '.0';
return result;
}
}else if (o instanceof Array){
if (!o.length) return indent+"[]";
var pieces = o.map(function(v){ return build(v,'') });
var oneLine = indent+'['+apad+pieces.join(comma)+apad+']';
let pieces = o.map(function(v){ return build(v,'',floatsForced) });
const oneLine = indent+'['+apad+pieces.join(comma)+apad+']';
if (opts.wrap===false || oneLine.length<=opts.wrap) return oneLine;
if (opts.short){
var indent2 = indent+' '+apad;
pieces = o.map(function(v){ return build(v,indent2) });
const indent2 = indent+' '+apad;
pieces = o.map(function(v){ return build(v,indent2,floatsForced) });
pieces[0] = pieces[0].replace(indent2,indent+'['+apad);

@@ -59,10 +72,10 @@ pieces[pieces.length-1] = pieces[pieces.length-1]+apad+']';

}else{
var indent2 = indent+opts.indent;
return indent+'[\n'+o.map(function(v){ return build(v,indent2) }).join(',\n')+'\n'+(opts.indentLast?indent2:indent)+']';
const indent2 = indent+opts.indent;
return indent+'[\n'+o.map(function(v){ return build(v,indent2,floatsForced) }).join(',\n')+'\n'+(opts.indentLast?indent2:indent)+']';
}
}else if (o instanceof Object){
var sortedKV=[],i=0;
var sort = opts.sort || opts.sorted;
for (var k in o){
var kv = sortedKV[i++] = [k,o[k]];
let sortedKV=[], i=0;
const sort = opts.sort || opts.sorted;
for (let k in o){
const kv = sortedKV[i++] = [k,o[k]];
if (sort===true) kv[2] = k;

@@ -73,6 +86,4 @@ else if (typeof sort==='function') kv[2]=sort(k,o[k],o);

if (sort) sortedKV = sortedKV.sort(function(a,b){ a=a[2]; b=b[2]; return a<b?-1:a>b?1:0 });
var keyvals=sortedKV.map(function(kv){ return [JSON.stringify(kv[0]), build(kv[1],'')] });
if (opts.sorted) keyvals = keyvals.sort(function(kv1,kv2){ kv1=kv1[0]; kv2=kv2[0]; return kv1<kv2?-1:kv1>kv2?1:0 });
keyvals = keyvals.map(function(kv){ return kv.join(colon1) }).join(comma);
var oneLine = indent+"{"+opad+keyvals+opad+"}";
let keyvals=sortedKV.map(([k,v]) => [JSON.stringify(k), build(v,'',(opts.forceFloats || opts.forceFloatsIn.includes(k)))].join(colon1) ).join(comma);
const oneLine = indent+"{"+opad+keyvals+opad+"}";
if (opts.wrap===false || oneLine.length<opts.wrap) return oneLine;

@@ -83,34 +94,28 @@ if (opts.short){

if (opts.aligned){
var longest = 0;
for (var i=keyvals.length;i--;) if (keyvals[i][0].length>longest) longest = keyvals[i][0].length;
var padding = repeat(' ',longest);
for (var i=keyvals.length;i--;) keyvals[i][0] = padRight(padding,keyvals[i][0]);
let longest = 0;
for (let i=keyvals.length;i--;) if (keyvals[i][0].length>longest) longest = keyvals[i][0].length;
const padding = repeat(' ',longest);
for (let i=keyvals.length;i--;) keyvals[i][0] = padRight(padding,keyvals[i][0]);
}
for (var i=keyvals.length;i--;){
var k=keyvals[i][0], v=keyvals[i][1];
var indent2 = repeat(' ',(k+colonN).length);
var oneLine = k+colonN+build(v,'');
keyvals[i] = (opts.wrap===false || oneLine.length<=opts.wrap || !v || typeof v!="object") ? oneLine : (k+colonN+build(v,indent2).replace(/^\s+/,''));
for (let i=keyvals.length;i--;){
let k=keyvals[i][0], v=keyvals[i][1];
const indent2 = repeat(' ',(k+colonN).length);
floatsForced = (opts.forceFloats || opts.forceFloatsIn.includes(k));
const oneLine = k+colonN+build(v,'',floatsForced);
keyvals[i] = (opts.wrap===false || oneLine.length<=opts.wrap || !v || typeof v!="object") ? oneLine : (k+colonN+build(v,indent2,floatsForced).replace(/^\s+/,''));
}
return keyvals.join(',\n') + opad + '}';
}else{
var keyvals=[],i=0;
// TODO: share this code with sortedKV above
for (var k in o){
var kv = keyvals[i++] = [indent+opts.indent+JSON.stringify(k),o[k]];
if (sort===true) kv[2] = k;
else if (typeof sort==='function') kv[2]=sort(k,o[k],o);
}
if (sort) keyvals = keyvals.sort(function(a,b){ a=a[2]; b=b[2]; return a<b?-1:a>b?1:0 });
const keyvals=sortedKV.map(function(kvs){ kvs[0] = indent+opts.indent+JSON.stringify(kvs[0]); return kvs });
if (opts.aligned){
var longest = 0;
for (var i=keyvals.length;i--;) if (keyvals[i][0].length>longest) longest = keyvals[i][0].length;
var padding = repeat(' ',longest);
for (var i=keyvals.length;i--;) keyvals[i][0] = padRight(padding,keyvals[i][0]);
let longest = 0;
for (let i=keyvals.length;i--;) if (keyvals[i][0].length>longest) longest = keyvals[i][0].length;
const padding = repeat(' ',longest);
for (let i=keyvals.length;i--;) keyvals[i][0] = padRight(padding,keyvals[i][0]);
}
var indent2 = indent+opts.indent;
for (var i=keyvals.length;i--;){
var k=keyvals[i][0], v=keyvals[i][1];
var oneLine = k+colonN+build(v,'');
keyvals[i] = (opts.wrap===false || oneLine.length<=opts.wrap || !v || typeof v!="object") ? oneLine : (k+colonN+build(v,indent2).replace(/^\s+/,''));
const indent2 = indent+opts.indent;
for (let i=keyvals.length;i--;){
const k=keyvals[i][0], v=keyvals[i][1];
const oneLine = k+colonN+build(v,'',floatsForced);
keyvals[i] = (opts.wrap===false || oneLine.length<=opts.wrap || !v || typeof v!="object") ? oneLine : (k+colonN+build(v,indent2,floatsForced).replace(/^\s+/,''));
}

@@ -126,3 +131,3 @@ return indent+'{\n'+keyvals.join(',\n')+'\n'+(opts.indentLast?indent2:indent)+'}'

function repeat(str,times){ // http://stackoverflow.com/a/17800645/405017
var result = '';
let result = '';
while(true){

@@ -141,4 +146,4 @@ if (times & 1) result += str;

}
neatJSON.version = "0.8.3";
neatJSON.version = "0.10";
})(typeof exports === 'undefined' ? this : exports);

@@ -1,2 +0,2 @@

Copyright (c) 2015-2016 Gavin Kistner
Copyright (c) 2015-2019 Gavin Kistner

@@ -7,2 +7,2 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
{
"name": "neatjson",
"version": "0.8.3",
"version": "0.10.0",
"description": "Pretty, powerful, flexible JSON generation.",

@@ -5,0 +5,0 @@ "main": "./javascript/neatjson.js",

@@ -6,3 +6,3 @@ # NeatJSON

Pretty-print your JSON in Ruby or JavaScript with more power than is provided by `JSON.pretty_generate` (Ruby) or `JSON.stringify` (JS). For example, like Ruby's `pp` (pretty print), NeatJSON can keep objects on one line if they fit, but break them over multiple lines if needed.
Pretty-print your JSON in Ruby or JavaScript or Lua with more power than is provided by `JSON.pretty_generate` (Ruby) or `JSON.stringify` (JS). For example, like Ruby's `pp` (pretty print), NeatJSON can keep objects on one line if they fit, but break them over multiple lines if needed.

@@ -21,38 +21,21 @@ **Features (all optional):**

* [Online webpage](http://phrogz.net/JS/NeatJSON) for conversions and experimenting with options.
* [Lua only] Produce Lua table serialization.
Here's a short example of output showing the power of proper wrapping:
~~~ json
{
"navigation.createroute.poi":[
{"text":"Lay in a course to the Hilton","params":{"poi":"Hilton"}},
{"text":"Take me to the airport","params":{"poi":"airport"}},
{"text":"Let's go to IHOP","params":{"poi":"IHOP"}},
{"text":"Show me how to get to The Med","params":{"poi":"The Med"}},
{"text":"Create a route to Arby's","params":{"poi":"Arby's"}},
{
"text":"Go to the Hilton by the Airport",
"params":{"poi":"Hilton","location":"Airport"}
},
{
"text":"Take me to the Fry's in Fresno",
"params":{"poi":"Fry's","location":"Fresno"}
}
],
"navigation.eta":[
{"text":"When will we get there?"},
{"text":"When will I arrive?"},
{"text":"What time will I get to the destination?"},
{"text":"What time will I reach the destination?"},
{"text":"What time will it be when I arrive?"}
]
}
~~~
## Table of Contents
* [Installation](#installation)
* [Usage](#usage)
* [Examples](#examples)
* [Options](#options)
* [License & Contact](#license--contact)
* [TODO/Known Limitations](#todo-aka-known-limitations)
* [History](#history)
## Installation
* Ruby: `gem install neatjson`
* JavaScript: Clone the GitHub repo and copy `javascript/neatjson.js`
* _Sorry, no NodeJS package yet._
* JavaScript (web): Clone the GitHub repo and copy `javascript/neatjson.js`
* Node.js: `npm install neatjson`

@@ -69,4 +52,5 @@

**JavaScript**:
**JavaScript (web)**:
~~~ html

@@ -80,5 +64,20 @@ <script type="text/javascript" src="neatjson.js"></script>

**Node.js**:
~~~ js
const { neatJSON } = require('neatjson');
var json = neatJSON( value, options );
~~~
**Lua**:
~~~ lua
local neatJSON = require'neatjson'
local json = neatJSON(value, options)
~~~
## Examples
_The following are all in Ruby._
_The following are all in Ruby, but similar options apply in JavaScript and Lua._

@@ -180,26 +179,47 @@ ~~~ ruby

## Options
You may pass any of the following options to `neat_generate` (Ruby) or `neatJSON` (JavaScript):
You may pass any of the following options to `neat_generate` (Ruby) or `neatJSON` (JavaScript/Lua). **Note**: option names with underscores below use camelCase in JavaScript and Lua. For example:
* `wrap` — Maximum line width before wrapping. Use `false` to never wrap, `true` to always wrap. default:`80`
* `indent` — Whitespace used to indent each level when wrapping. default:`" "` (two spaces)
* `indent_last` — Indent the closing bracket/brace for arrays and objects? default:`false`
* `short` — Put opening brackets on the same line as the first value, closing brackets on the same line as the last? default:`false`
~~~ ruby
# Ruby
json = JSON.neat_generate my_value, array_padding:1, after_comma:1, before_colon_n:2, indent_last:true
~~~
~~~ js
// JavaScript
var json = neatJSON( myValue, { arrayPadding:1, afterComma:1, beforeColonN:2, indentLast:true } );
~~~
~~~ lua
-- Lua
local json = neatJSON( myValue, { arrayPadding=1, afterComma=1, beforeColonN=2, indentLast=true } )
~~~
* `wrap` — Maximum line width before wrapping. Use `false` to never wrap, `true` to always wrap. default:`80`
* `indent` — Whitespace used to indent each level when wrapping. default:`" "` (two spaces)
* `indent_last` — Indent the closing bracket/brace for arrays and objects? default:`false`
* `short` — Put opening brackets on the same line as the first value, closing brackets on the same line as the last? default:`false`
* _This causes the `indent` and `indent_last` options to be ignored, instead basing indentation on array and object padding._
* `sort` — Sort objects' keys in alphabetical order (`true`), or supply a lambda for custom sorting. default:`false`
* `sort` — Sort objects' keys in alphabetical order (`true`), or supply a lambda for custom sorting. default:`false`
* If you supply a lambda to the `sort` option, it will be passed three values: the (string) name of the key, the associated value, and the object being sorted, e.g. `{ sort:->(key,value,hash){ Float(value) rescue Float::MAX } }`
* `aligned` — When wrapping objects, line up the colons (per object)? default:`false`
* `decimals` — Decimal precision for non-integer numbers; use `false` to keep values precise. default:`false`
* `array_padding` — Number of spaces to put inside brackets for arrays. default:`0`
* `object_padding` — Number of spaces to put inside braces for objects. default:`0`
* `padding` — Shorthand to set both `array_padding` and `object_padding`. default:`0`
* `before_comma` — Number of spaces to put before commas (for both arrays and objects). default:`0`
* `after_comma` — Number of spaces to put after commas (for both arrays and objects). default:`0`
* `around_comma` — Shorthand to set both `before_comma` and `after_comma`. default:`0`
* `before_colon_1` — Number of spaces before a colon when the object is on one line. default:`0`
* `after_colon_1` — Number of spaces after a colon when the object is on one line. default:`0`
* `before_colon_n` — Number of spaces before a colon when the object is on multiple lines. default:`0`
* `after_colon_n` — Number of spaces after a colon when the object is on multiple lines. default:`0`
* `before_colon` — Shorthand to set both `before_colon_1` and `before_colon_n`. default:`0`
* `after_colon` — Shorthand to set both `after_colon_1` and `after_colon_n`. default:`0`
* `around_colon` — Shorthand to set both `before_colon` and `after_colon`. default:`0`
* `aligned` — When wrapping objects, line up the colons (per object)? default:`false`
* `decimals` — Decimal precision for non-integer numbers; use `false` to keep values precise. default:`false`
* `trim_trailing_zeros` — Remove extra zeros at the end of floats, e.g. `1.2000` becomes `1.2`. default:`false`
* `force_floats` — Force every integer value written to the file to be a float, e.g. `12` becomes `12.0`. default:`false`
* `force_floats_in` — Specify an array of object key names under which all integer values are treated as floats.
For example, serializing `{a:[1, 2, {a:3, b:4}], c:{a:5, d:6}` with `force_floats_in:['a']` would produce `{"a":[1.0, 2.0, {"a":3.0, "b":4}], "c":{"a":5.0, "d":6}}`.
* `array_padding` — Number of spaces to put inside brackets for arrays. default:`0`
* `object_padding` — Number of spaces to put inside braces for objects. default:`0`
* `padding` — Shorthand to set both `array_padding` and `object_padding`. default:`0`
* `before_comma` — Number of spaces to put before commas (for both arrays and objects). default:`0`
* `after_comma` — Number of spaces to put after commas (for both arrays and objects). default:`0`
* `around_comma` — Shorthand to set both `before_comma` and `after_comma`. default:`0`
* `before_colon_1` — Number of spaces before a colon when the object is on one line. default:`0`
* `after_colon_1` — Number of spaces after a colon when the object is on one line. default:`0`
* `before_colon_n` — Number of spaces before a colon when the object is on multiple lines. default:`0`
* `after_colon_n` — Number of spaces after a colon when the object is on multiple lines. default:`0`
* `before_colon` — Shorthand to set both `before_colon_1` and `before_colon_n`. default:`0`
* `after_colon` — Shorthand to set both `after_colon_1` and `after_colon_n`. default:`0`
* `around_colon` — Shorthand to set both `before_colon` and `after_colon`. default:`0`
* `lua` — (Lua only) Output a Lua table literal instead of JSON? default:`false`
* `emptyTablesAreObjects` — (Lua only) Should `{}` in Lua become a JSON object (`{}`) or JSON array (`[]`)? default:`false` (array)

@@ -244,3 +264,3 @@ You may omit the 'value' and/or 'object' parameters in your `sort` lambda if desired. For example:

_Note that the JavaScript version of NeatJSON does not provide a mechanism for cascading sort in the same manner as Ruby._
_Note that the JavaScript and Lua versions of NeatJSON do not provide a mechanism for cascading sort in the same manner as Ruby._

@@ -250,3 +270,3 @@

NeatJSON is copyright ©2015–2017 by Gavin Kistner and is released under
NeatJSON is copyright ©2015–2022 by Gavin Kistner and is released under
the [MIT License](http://www.opensource.org/licenses/mit-license.php).

@@ -263,3 +283,2 @@ See the LICENSE.txt file for more details.

* Detect circular references.
* Possibly allow illegal JSON values like `NaN` or `Infinity`.
* Possibly allow "JSON5" output (legal identifiers unquoted, etc.)

@@ -270,2 +289,16 @@

* **v0.10** — August 29, 2022
* Add `force_floats` and `force_floats_in` to support serialization for non-standard parsers that differentiate between integers and floats.
* Add `trim_trailing_zeros` option to convert the `decimals` output from e.g. `5.40000` to `5.4`.
* Convert JavaScript version to require ECMAScript 6 for performance.
* **v0.9** — July 29, 2019
* Add Lua version, serializing to both JSON and Lua table literals
* All languages serialize Infinity/-Infinity to JSON as `9e9999` and `-9e9999`
* All languages serialize NaN to JSON as `"NaN"`
* **v0.8.4** — May 3, 2018
* Fix issue #27: Default sorting fails with on objects with mixed keys [Ruby only]
* _Thanks Reid Beels_
* **v0.8.3** — February 20, 2017

@@ -272,0 +305,0 @@ * Fix issue #25: Sorting keys on multi-line object **using function** does not work without "short" [JS only]

@@ -0,0 +0,0 @@ [ { "_id" : "571a50573f1fe7fd05093129",

@@ -18,2 +18,5 @@ exports.tests = [

{json:"5.000", opts:{decimals:3}},
{json:"5", opts:{decimals:3, trimTrailingZeros:true}},
{json:"5.0", opts:{decimals:3, trimTrailingZeros:true, forceFloats:true}},
{json:"5.000", opts:{decimals:3, trimTrailingZeros:false, forceFloats:true}},
]},

@@ -34,3 +37,2 @@ {value:4.2, tests:[

{value:"foo", tests:[{json:"\"foo\""}]},
// {value: :foo, tests:[{json:"\"foo\""}]},
{value:"foo\nbar", tests:[{json:"\"foo\\nbar\""}]},

@@ -174,2 +176,34 @@

{value:{inf:1/0, neginf:-1/0, nan:0/0}, tests:[
{ json:'{"inf":9e9999,"nan":"NaN","neginf":-9e9999}', opts:{sort:true} },
]},
{value:[0, 1, 1.1, 1.555555], tests:[
{ json:'[0,1,1.1,1.555555]', opts:{forceFloats:false} },
{ json:'[0.0,1.0,1.1,1.555555]', opts:{forceFloats:true} },
{ json:'[0.000,1.000,1.100,1.556]', opts:{forceFloats:true, decimals:3} },
{ json:'[0.0,1.0,1.1,1.556]', opts:{forceFloats:true, decimals:3, trimTrailingZeros:true} },
{ json:'[0,1,1.1,1.556]', opts:{forceFloats:false, decimals:3, trimTrailingZeros:true} },
]},
{value:{floats:[0, 1, 0.1, 1.555555], raw:[0, 1, 0.1, 1.555555]}, tests:[
{ json:'{"floats":[0,1,0.1,1.555555],"raw":[0,1,0.1,1.555555]}', opts:{forceFloats:false} },
{ json:'{"floats":[0.0,1.0,0.1,1.555555],"raw":[0.0,1.0,0.1,1.555555]}', opts:{forceFloats:true} },
{ json:'{"floats":[0.0,1.0,0.1,1.555555],"raw":[0,1,0.1,1.555555]}', opts:{forceFloatsIn:['floats']} },
{ json:'{"floats":[0,1,0.100,1.556],"raw":[0,1,0.100,1.556]}', opts:{forceFloats:false, decimals:3} },
{ json:'{"floats":[0.000,1.000,0.100,1.556],"raw":[0.000,1.000,0.100,1.556]}', opts:{forceFloats:true, decimals:3} },
{ json:'{"floats":[0.000,1.000,0.100,1.556],"raw":[0,1,0.100,1.556]}', opts:{forceFloatsIn:['floats'], decimals:3} },
{ json:'{"floats":[0,1,0.1,1.556],"raw":[0,1,0.1,1.556]}', opts:{forceFloats:false, decimals:3, trimTrailingZeros:true} },
{ json:'{"floats":[0.0,1.0,0.1,1.556],"raw":[0.0,1.0,0.1,1.556]}', opts:{forceFloats:true, decimals:3, trimTrailingZeros:true} },
{ json:'{"floats":[0.0,1.0,0.1,1.556],"raw":[0,1,0.1,1.556]}', opts:{forceFloatsIn:['floats'], decimals:3, trimTrailingZeros:true} },
]},
{value:[1,2,3,{a:[4,5,{a:6, b:7}], b:[8,9,{a:10, b:11}]}], tests:[
{ json:'[1,2,3,{"a":[4,5,{"a":6,"b":7}],"b":[8,9,{"a":10,"b":11}]}]', opts:{} },
{ json:'[1.0,2.0,3.0,{"a":[4.0,5.0,{"a":6.0,"b":7.0}],"b":[8.0,9.0,{"a":10.0,"b":11.0}]}]', opts:{forceFloats:true, wrap:false} },
{ json:'[1,2,3,{"a":[4.0,5.0,{"a":6.0,"b":7}],"b":[8,9,{"a":10.0,"b":11}]}]', opts:{forceFloatsIn:['a'], wrap:false} },
]},
// {value:Class.new{ def to_json(*a); {a:1}.to_json(*a); end }.new, tests:[

@@ -176,0 +210,0 @@ // { json:'{ "a":1}' },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc