jimhigson / oboe.js

A streaming approach to JSON. Oboe.js speeds up web applications by providing parsed objects before the response completes.
http://oboejs.com
Other
4.76k stars 208 forks source link

unable to parse keys that are empty strings #108

Open tmkujala opened 8 years ago

tmkujala commented 8 years ago

Hi,

When parsing JSON that looks like this:

{
  "key1": "value1",
  "": "value2"
}

An error is thrown and the parsing is unsuccessful:

TypeError: Cannot read property '0' of undefined
    at C:\test\node_modules\oboe\dist\oboe-node.js:121:33
    at appendBuiltContent (C:\test\node_modules\oboe\dist\oboe-node.js:1453:15)
    at nodeOpened (C:\test\node_modules\oboe\dist\oboe-node.js:1434:7)
    at C:\test\node_modules\oboe\dist\oboe-node.js:1048:19
    at applyEach (C:\test\node_modules\oboe\dist\oboe-node.js:496:20)
    at emit (C:\test\node_modules\oboe\dist\oboe-node.js:1929:10)
    at handleData (C:\test\node_modules\oboe\dist\oboe-node.js:860:18)
    at applyEach (C:\test\node_modules\oboe\dist\oboe-node.js:496:20)
    at Object.emit (C:\test\node_modules\oboe\dist\oboe-node.js:1929:10)
    at ReadStream.<anonymous> (C:\test\node_modules\oboe\dist\oboe-node.js:1128:34)

The issue is with empty strings that are property keys. This error was originally posted in #86, but it doesn't appear to be related to that issue. I've spent a few hours trying to debug the issue, but have come up empty handed.

richardspence commented 8 years ago

+1 I have the same issue

tmkujala commented 8 years ago

I've found and fixed the issue, which is in the forked clarinet module. I ended up fixing it in the current clarinet project as well (dscape/clarinet#43) just to get some more unit tests running against my logic. I'll be filing a pull request against oboe.js shortly.

JuanCaicedo commented 7 years ago

I verified the problem here https://square-gem.hyperdev.space/