简体   繁体   English

ajax jquery请求中的json对象

[英]json object in ajax jquery request

I have the following HTTP request workload 我有以下HTTP请求工作量

  {jsonObj={"Nids":"<Id>20</Id><Id>22</Id>","Mids":"\"<Id>337</Id><Id>330</Id><Id>333</Id><Id>335</Id><Id>328</Id>\"","PageNo":"\"3\""}} 

I have the following error Invalid object passed in, \':\' or \'}\' expected 我传入了以下错误无效对象,\\ u0027:\\ u0027或\\ u0027} \\ u0027

what could be the problem ? 可能是什么问题呢 ?

This is not valid JSON. 这是无效的JSON。 Try: 尝试:

{jsonObj:{"Nids":"<Id>20</Id><Id>22</Id>","Mids":"\"<Id>337</Id><Id>330</Id><Id>333</Id><Id>335</Id><Id>328</Id>\"","PageNo":"\"3\""}}

replace jsonObj= with jsonObj: jsonObj=替换为jsonObj:

Notice : instead of = 注意:代替=

The JsonObj is not valid. JsonObj无效。 The below works. 下面的作品。

Use JSON.stringify as much as possible. 尽可能使用JSON.stringify

> obj='{"jsonObj":{"Nids":"<Id>20</Id><Id>22</Id>","Mids":"<Id>337</Id><Id>330</Id><Id>333</Id><Id>335</Id><Id>328</Id>","PageNo":"3"}}'
'{"jsonObj":{"Nids":"<Id>20</Id><Id>22</Id>","Mids":"<Id>337</Id><Id>330</Id><Id>333</Id><Id>335</Id><Id>328</Id>","PageNo":"3"}}'
> JSON.parse(obj)
{ jsonObj:
   { Nids: '<Id>20</Id><Id>22</Id>',
     Mids: '<Id>337</Id><Id>330</Id><Id>333</Id><Id>335</Id><Id>328</Id>',
     PageNo: '3' } }
>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM