xadillax / fbibik-json Goto Github PK
View Code? Open in Web Editor NEWParse JSON-Object string (not normalized JSON string) into JSON object.
License: MIT License
Parse JSON-Object string (not normalized JSON string) into JSON object.
License: MIT License
{
// b = 2
a:1,
b:2,
c:3
}
=>
{ b: 2, c: 3 }
Reproduct code:
const fJSON = require('fbbk-json')
console.log(fJSON.parse("{a: '123'}")) // works great
console.log(fJSON.parse("'123'")) // cannot work, an error thrown
Error Message:
TypeError: Cannot assign to read only property '0' of string ''123''
at parse (/your/project/path/node_modules/fbbk-json/fjson.js:214:39)
at Object.g.parse (/your/project/path/node_modules/fbbk-json/fjson.js:353:26)
Source Code:
https://github.com/XadillaX/fbibik-json/blob/master/fjson.js#L214
😂
试试这个?
fJSON.parse("決")
引起错误的 demo
var fJSON = require("fbbk-json");
var str = JSON.stringify({"footer":{"text":"原因:错误,I'm the","linkTemporary":"" } });
fJSON.parse(str);
错误信息
node_modules/fbbk-json/fjson.js:137
throw new Error("Broken JSON " + (str[pos] === "{" ? "object" : "array") + " body near " + body);
示例JSON 如下
{
"level1": {
"level2": "with character [,],{,} "
}
}
尝试解析
fbbk.parse('{"level1": {"level2": "with character [,],{,} "}');
抛出错误
Error: Broken JSON object near {"level1": {"level2": "with character [,],{,} "}
at parse (/Users/plusman/Desktop/dasouche/github/fbibik-json/fjson.js:235:19)
at Object.g.parse (/Users/plusman/Desktop/dasouche/github/fbibik-json/fjson.js:280:26)
at Object.<anonymous> (/Users/plusman/Desktop/dasouche/github/fbibik-json/test/bug.js:3:16)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.