express - Expressjs Invalid JSON when data is just a string -
searching has proven difficult, since people asking have object have serialized (incorrectly).
i sending string
. not object, string
. here request right before it's fired off. json.parse
can handle payload fine. string double quoted, per the spec.
express js gives simple error: error: invalid json
. need send string payload?
by default express.bodyparser()
, based on connect
json
middleware operates in strict mode. strict mode parse objects or arrays, sticking strictly json spec.
json built on 2 structures:
a collection of name/value pairs. in various languages, realized object, record, struct, dictionary, hash table, keyed list, or associative array.
an ordered list of values. in languages, realized array, vector, list, or sequence.
if want non-strict version, can optionally using option use json.parse
, ok parsing string representation of raw json value 'true', '"stackoverflow"', '42', , on.
app.use(connect.bodyparser({strict: false}));
Comments
Post a Comment