GithubHelp home page GithubHelp logo

fbibik-json's Issues

Cannot parse '123' json string, but {a: '123'} works fine.

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
😂

Json 字符串解析错误

引起错误的 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字符串中,如果键值对包含“[,],{,}”,会发生解析错误

示例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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.