node.js - Node Express parses request body with JSON incorrectly -


i sending json object web client, looks this:

{"audioencoder":{"settings":{"1":{"audio_bitrate":"16000"}}}} 

and in request req.body.myvalue:

{"audioencoder":{"settings":[null,{"audio_bitrate":"16000"}]}} 

in network panel of browser see correct value though:

myvalue[audioencoder][settings][1][audio_bitrate]:16000 

error expecting object key {1:... [null:....

any ideas why happen?

i suspect browser isn't sending json, it's sending application/x-www-form-urlencoded. not correct value if trying have browser send json: myvalue[audioencoder][settings][1][audio_bitrate]:16000. that's not json. check request headers content-type , @ raw body of request verify this. if post browser js that's sending ajax, can fix that. jquery makes little tricky specify options correctly send json.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -