Comparing version
@@ -15,7 +15,4 @@ { | ||
"./transform" | ||
], | ||
"bindings": "esm", | ||
"exportStart": "_start" | ||
}, | ||
"extends": "./node_modules/@assemblyscript/wasi-shim/asconfig.json" | ||
] | ||
} | ||
} |
@@ -12,5 +12,5 @@ import { JSON } from ".."; | ||
class Vec3 { | ||
x: f32; | ||
y: f32; | ||
z: f32; | ||
x: f64; | ||
y: f64; | ||
z: f64; | ||
} | ||
@@ -140,2 +140,3 @@ | ||
it("should ser/de string arrays", () => { | ||
// ["abcdefg","st\\"ring\\" w\\"\\"ith quotes\\"","string \\t\\r\\"with ran\\tdom spa\\nces and \\nnewlines\\n\\n\\n","string with colon : comma , brace [ ] bracket { } and quote \\" and other quote \\""] | ||
canSerde<string[]>([ | ||
@@ -142,0 +143,0 @@ "abcdefg", |
@@ -244,3 +244,3 @@ import { u128, u128Safe, u256, u256Safe, i128, i128Safe } from "as-bignum/assembly"; | ||
// @ts-ignore | ||
if (type instanceof f64) return f32.parse(data); | ||
if (type instanceof f64) return f64.parse(data); | ||
// @ts-ignore | ||
@@ -272,3 +272,3 @@ else if (type instanceof f32) return f32.parse(data); | ||
let isKey = false; | ||
let depth = 1; | ||
let depth = 0; | ||
let char = 0; | ||
@@ -286,6 +286,6 @@ let outerLoopIndex = 1; | ||
if (char === leftBracketCode) { | ||
depth = depth << 1; | ||
depth++; | ||
} else if (char === rightBracketCode) { | ||
depth = depth >> 1; | ||
if (depth === 1) { | ||
depth--; | ||
if (depth === 0) { | ||
++arrayValueIndex; | ||
@@ -308,6 +308,6 @@ // @ts-ignore | ||
if (char === leftBraceCode) { | ||
depth = depth << 1; | ||
depth++; | ||
} else if (char === rightBraceCode) { | ||
depth = depth >> 1; | ||
if (depth === 1) { | ||
depth--; | ||
if (depth === 0) { | ||
++objectValueIndex; | ||
@@ -314,0 +314,0 @@ // @ts-ignore |
import { u128 } from "as-bignum/assembly"; | ||
import { Candle } from "./Candle"; | ||
import { | ||
@@ -7,2 +6,11 @@ JSON | ||
const exp = `["abcdefg","st\\"ring\\" w\\"\\"ith quotes\\"","string \\t\\r\\"with ran\\tdom spa\\nces and \\nnewlines\\n\\n\\n","string with colon : comma , brace [ ] bracket { } and quote \\" and other quote \\""]`; | ||
console.log(exp); | ||
console.log(JSON.stringify([ | ||
"abcdefg", | ||
'st"ring" w""ith quotes"', | ||
'string \t\r"with ran\tdom spa\nces and \nnewlines\n\n\n', | ||
'string with colon : comma , brace [ ] bracket { } and quote " and other quote "', | ||
])) | ||
// @ts-ignore | ||
@@ -9,0 +17,0 @@ @JSON |
{ | ||
"name": "json-as", | ||
"version": "0.5.19", | ||
"version": "0.5.20", | ||
"description": "JSON encoder/decoder for AssemblyScript", | ||
@@ -28,3 +28,2 @@ "types": "assembly/index.ts", | ||
"@assemblyscript/wasi-shim": "^0.1.0", | ||
"as-bignum": "^0.2.23", | ||
"assemblyscript": "^0.27.0", | ||
@@ -38,3 +37,4 @@ "assemblyscript-prettier": "^1.0.7", | ||
"as-string-sink": "^0.5.0", | ||
"as-variant": "^0.4.1" | ||
"as-variant": "^0.4.1", | ||
"as-bignum": "^0.2.23" | ||
}, | ||
@@ -41,0 +41,0 @@ "repository": { |
@@ -76,24 +76,6 @@ # AS-JSON | ||
# FAQ | ||
# Notes | ||
**Does it support the JSON specification?** | ||
Performance is nearly equal to the JavaScript JSON implementation which is in C++. | ||
Yes, it does. However, dynamic objects and arrays are not supported, but planned in the near future. | ||
**Is it fast?** | ||
Look below | ||
**How does it compare to other libs?** | ||
Its pretty much the same as the other libraries out there (near/assemblyscript-json and @serial-as/json), but it focuses highly on performance | ||
**Will it catch invalid JSON?** | ||
No, it does not check for invalid JSON, but gives its best shot at parsing instead. Will probably throw an error. | ||
**How does it compare performance-wise to other libraries?** | ||
In my testing, parsing a Vector 2 runs at 2.2m ops/s with as-json and around 10,000 ops/s with assemblyscript-json and @serial-as/json. | ||
Both are great libraries however. | ||
## Performance | ||
@@ -100,0 +82,0 @@ |
{ | ||
"name": "@json-as/transform", | ||
"version": "0.5.19", | ||
"version": "0.5.20", | ||
"description": "JSON encoder/decoder for AssemblyScript", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
9
-10%63957
-0.9%3
50%2467
-12.18%24
-4%1432
-0.83%96
-15.79%+ Added
+ Added