You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
no detailed error message at all. It turns out the returned value from fs.readFileSync is not a string (typeof content is object), and JSON.parse expects a String as input
Workaround is to wrap the result of fs.readFileSync in a String, like this:
var sys=require("sys"), fs=require("fs");
var content=String(fs.readFileSync("a.json"));
sys.puts(JSON.parse(content));
this is a regression: the first code snippet worked fine with nodejs at:
commit 320d3e9
Fri May 14 11:15:31 2010 -0700
The text was updated successfully, but these errors were encountered:
run the following code:
file a.json (referenced above) can be any file containing any valid json (like:
{"a":1}
will do)this is the output (nodejs 0.1.98):
no detailed error message at all. It turns out the returned value from
fs.readFileSync
is not a string (typeof content
isobject
), andJSON.parse
expects aString
as inputWorkaround is to wrap the result of
fs.readFileSync
in aString
, like this:this is a regression: the first code snippet worked fine with nodejs at:
commit 320d3e9
Fri May 14 11:15:31 2010 -0700
The text was updated successfully, but these errors were encountered: