Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 在Objective C中处理Json回调API_Objective C - Fatal编程技术网

Objective c 在Objective C中处理Json回调API

Objective c 在Objective C中处理Json回调API,objective-c,Objective C,我不熟悉目标C编程。我对目标C&json响应有问题。我正在尝试从谷歌字典API获取单词定义。我得到了Json的回应。但问题是我得到了回复。json无法轻松解析。 我调用的API是 http://www.google.com/dictionary/json?callback=dict_api.callbacks.id100&q=test&sl=en&tl=en&restrict=prCde&client=te 我得到的回应是 dict_api.callba

我不熟悉目标C编程。我对目标C&json响应有问题。我正在尝试从谷歌字典API获取单词定义。我得到了Json的回应。但问题是我得到了回复。json无法轻松解析。 我调用的API是

http://www.google.com/dictionary/json?callback=dict_api.callbacks.id100&q=test&sl=en&tl=en&restrict=prCde&client=te
我得到的回应是

dict_api.callbacks.id100({"query":"test","sourceLanguage":"en","targetLanguage":"en","primaries":[{"type":"headword","terms":[{"type":"text","text":"test","language":"en","labels":[{"text":"Noun","title":"Part-of-speech"}]},{"type":"phonetic","text":"/test/","language":"und"},{"type":"sound","text":"http://www.gstatic.com/dictionary/static/sounds/de/0/test.mp3","language":"und"}],"entries":[{"type":"related","terms":[{"type":"text","text":"tests","language":"und","labels":[{"text":"plural"}]}]},{"type":"meaning","terms":[{"type":"text","text":"A procedure intended to establish the quality, performance, or reliability of something, esp. before it is taken into widespread use","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"no sparking was visible during the \x3cem\x3etests\x3c/em\x3e","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"A short written or spoken examination of a person\x27s proficiency or knowledge","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"a spelling \x3cem\x3etest\x3c/em\x3e","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"An event or situation that reveals the strength or quality of someone or something by putting them under strain","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"this is the first serious \x3cem\x3etest\x3c/em\x3e of the peace agreement","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"An examination of part of the body or a body fluid for medical purposes, esp. by means of a chemical or mechanical procedure rather than simple inspection","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"a \x3cem\x3etest\x3c/em\x3e for HIV","language":"en"}]},{"type":"example","terms":[{"type":"text","text":"eye \x3cem\x3etests\x3c/em\x3e","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"A procedure employed to identify a substance or to reveal the presence or absence of a constituent within a substance","language":"en"}]},{"type":"meaning","terms":[{"type":"text","text":"The result of a medical examination or analytical procedure","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"a positive \x3cem\x3etest\x3c/em\x3e for protein","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"A means of establishing whether an action, item, or situation is an instance of a specified quality, esp. one held to be undesirable","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"a statutory \x3cem\x3etest\x3c/em\x3e of obscenity","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"A movable hearth in a reverberating furnace, used for separating gold or silver from lead","language":"en"}]}]},{"type":"headword","terms":[{"type":"text","text":"test","language":"en","labels":[{"text":"Verb","title":"Part-of-speech"}]},{"type":"phonetic","text":"/test/","language":"und"},{"type":"sound","text":"http://www.gstatic.com/dictionary/static/sounds/de/0/test.mp3","language":"und"}],"entries":[{"type":"related","terms":[{"type":"text","text":"tests","language":"und","labels":[{"text":"3rd person singular present"}]},{"type":"text","text":"tested","language":"und","labels":[{"text":"past participle"}]},{"type":"text","text":"testing","language":"und","labels":[{"text":"present participle"}]},{"type":"text","text":"tested","language":"und","labels":[{"text":"past tense"}]}]},{"type":"meaning","terms":[{"type":"text","text":"Take measures to check the quality, performance, or reliability of (something), esp. before putting it into widespread use or practice","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"this range has not been \x3cem\x3etested\x3c/em\x3e on animals","language":"en"}]},{"type":"example","terms":[{"type":"text","text":"the \x3cem\x3etesting\x3c/em\x3e and developing of prototypes","language":"en"}]},{"type":"example","terms":[{"type":"text","text":"a useful way to \x3cb\x3e\x3cem\x3etest\x3c/em\x3e out\x3c/b\x3e ideas before implementation","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"Reveal the strengths or capabilities of (someone or something) by putting them under strain","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"such behavior would severely \x3cem\x3etest\x3c/em\x3e any marriage","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"Give (someone) a short written or oral examination of their proficiency or knowledge","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"all children are \x3cem\x3etested\x3c/em\x3e at eleven","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"Judge or measure (someone\x27s proficiency or knowledge) by means of such an examination","language":"en"}]},{"type":"meaning","terms":[{"type":"text","text":"Carry out a medical \x3cem\x3etest\x3c/em\x3e on (a person, a part of the body, or a body fluid)","language":"en"}]},{"type":"meaning","terms":[{"type":"text","text":"Produce a specified result in a medical \x3cem\x3etest\x3c/em\x3e, esp. a drug \x3cem\x3etest\x3c/em\x3e or AIDS \x3cem\x3etest\x3c/em\x3e","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"he \x3cb\x3e\x3cem\x3etested\x3c/em\x3e positive\x3c/b\x3e for steroids during the race","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"Examine (a substance) by means of a reagent","language":"en"}]},{"type":"meaning","terms":[{"type":"text","text":"Touch or taste (something) to check that it is acceptable before proceeding further","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"she \x3cem\x3etested\x3c/em\x3e the water with the tip of her elbow","language":"en"}]}]}]},{"type":"headword","terms":[{"type":"text","text":"test","language":"en","labels":[{"text":"Noun","title":"Part-of-speech"}]},{"type":"sound","text":"http://www.gstatic.com/dictionary/static/sounds/de/0/test.mp3","language":"und"}],"entries":[{"type":"related","terms":[{"type":"text","text":"tests","language":"und","labels":[{"text":"plural"}]}]},{"type":"meaning","terms":[{"type":"text","text":"The shell or integument of some invertebrates and protozoans, esp. the chalky shell of a foraminiferan or the tough outer layer of a tunicate","language":"en"}]}]}]},200,null)
我正试图将此响应保存到NSArray中,如下所示:

SBJSON *jsonParser = [[SBJSON alloc] init];
NSArray *responseArray = [jsonParser objectWithString:responseString];
甚至我也用NSdictionary尝试了这段代码

SBJSON *jsonParser = [[SBJSON alloc] init];
NSDictionary *responseDict = [jsonParser objectWithString:responseString];

但我得到了一本空字典。我错在哪里?请帮助我。

SBJSON无法解析方法调用,您应该更改API调用,以仅返回JSON数据,而不是完整的回调方法调用

请尝试删除url的回调参数,以仅返回JSON数据,如下所示,该数据有效且可解析:

 {"query":"test","sourceLanguage":"en","targetLanguage":"en","primaries":[{"type":"headword","terms":[{"type":"text","text":"test","language":"en","labels":[{"text":"Noun","title":"Part-of-speech"}]},{"type":"phonetic","text":"/test/","language":"und"},{"type":"sound","text":"http://www.gstatic.com/dictionary/static/sounds/de/0/test.mp3","language":"und"}],"entries":[{"type":"related","terms":[{"type":"text","text":"tests","language":"und","labels":[{"text":"plural"}]}]},{"type":"meaning","terms":[{"type":"text","text":"A procedure intended to establish the quality, performance, or reliability of something, esp. before it is taken into widespread use","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"no sparking was visible during the \x3cem\x3etests\x3c/em\x3e","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"A short written or spoken examination of a person\x27s proficiency or knowledge","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"a spelling \x3cem\x3etest\x3c/em\x3e","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"An event or situation that reveals the strength or quality of someone or something by putting them under strain","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"this is the first serious \x3cem\x3etest\x3c/em\x3e of the peace agreement","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"An examination of part of the body or a body fluid for medical purposes, esp. by means of a chemical or mechanical procedure rather than simple inspection","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"a \x3cem\x3etest\x3c/em\x3e for HIV","language":"en"}]},{"type":"example","terms":[{"type":"text","text":"eye \x3cem\x3etests\x3c/em\x3e","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"A procedure employed to identify a substance or to reveal the presence or absence of a constituent within a substance","language":"en"}]},{"type":"meaning","terms":[{"type":"text","text":"The result of a medical examination or analytical procedure","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"a positive \x3cem\x3etest\x3c/em\x3e for protein","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"A means of establishing whether an action, item, or situation is an instance of a specified quality, esp. one held to be undesirable","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"a statutory \x3cem\x3etest\x3c/em\x3e of obscenity","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"A movable hearth in a reverberating furnace, used for separating gold or silver from lead","language":"en"}]}]},{"type":"headword","terms":[{"type":"text","text":"test","language":"en","labels":[{"text":"Verb","title":"Part-of-speech"}]},{"type":"phonetic","text":"/test/","language":"und"},{"type":"sound","text":"http://www.gstatic.com/dictionary/static/sounds/de/0/test.mp3","language":"und"}],"entries":[{"type":"related","terms":[{"type":"text","text":"tests","language":"und","labels":[{"text":"3rd person singular present"}]},{"type":"text","text":"tested","language":"und","labels":[{"text":"past participle"}]},{"type":"text","text":"testing","language":"und","labels":[{"text":"present participle"}]},{"type":"text","text":"tested","language":"und","labels":[{"text":"past tense"}]}]},{"type":"meaning","terms":[{"type":"text","text":"Take measures to check the quality, performance, or reliability of (something), esp. before putting it into widespread use or practice","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"this range has not been \x3cem\x3etested\x3c/em\x3e on animals","language":"en"}]},{"type":"example","terms":[{"type":"text","text":"the \x3cem\x3etesting\x3c/em\x3e and developing of prototypes","language":"en"}]},{"type":"example","terms":[{"type":"text","text":"a useful way to \x3cb\x3e\x3cem\x3etest\x3c/em\x3e out\x3c/b\x3e ideas before implementation","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"Reveal the strengths or capabilities of (someone or something) by putting them under strain","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"such behavior would severely \x3cem\x3etest\x3c/em\x3e any marriage","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"Give (someone) a short written or oral examination of their proficiency or knowledge","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"all children are \x3cem\x3etested\x3c/em\x3e at eleven","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"Judge or measure (someone\x27s proficiency or knowledge) by means of such an examination","language":"en"}]},{"type":"meaning","terms":[{"type":"text","text":"Carry out a medical \x3cem\x3etest\x3c/em\x3e on (a person, a part of the body, or a body fluid)","language":"en"}]},{"type":"meaning","terms":[{"type":"text","text":"Produce a specified result in a medical \x3cem\x3etest\x3c/em\x3e, esp. a drug \x3cem\x3etest\x3c/em\x3e or AIDS \x3cem\x3etest\x3c/em\x3e","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"he \x3cb\x3e\x3cem\x3etested\x3c/em\x3e positive\x3c/b\x3e for steroids during the race","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"Examine (a substance) by means of a reagent","language":"en"}]},{"type":"meaning","terms":[{"type":"text","text":"Touch or taste (something) to check that it is acceptable before proceeding further","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"she \x3cem\x3etested\x3c/em\x3e the water with the tip of her elbow","language":"en"}]}]}]},{"type":"headword","terms":[{"type":"text","text":"test","language":"en","labels":[{"text":"Noun","title":"Part-of-speech"}]},{"type":"sound","text":"http://www.gstatic.com/dictionary/static/sounds/de/0/test.mp3","language":"und"}],"entries":[{"type":"related","terms":[{"type":"text","text":"tests","language":"und","labels":[{"text":"plural"}]}]},{"type":"meaning","terms":[{"type":"text","text":"The shell or integument of some invertebrates and protozoans, esp. the chalky shell of a foraminiferan or the tough outer layer of a tunicate","language":"en"}]}]}]}

SBJSON无法解析方法调用,您应该更改API调用,使其仅返回JSON数据,而不返回完整的回调方法调用

请尝试删除url的回调参数,以仅返回JSON数据,如下所示,该数据有效且可解析:

 {"query":"test","sourceLanguage":"en","targetLanguage":"en","primaries":[{"type":"headword","terms":[{"type":"text","text":"test","language":"en","labels":[{"text":"Noun","title":"Part-of-speech"}]},{"type":"phonetic","text":"/test/","language":"und"},{"type":"sound","text":"http://www.gstatic.com/dictionary/static/sounds/de/0/test.mp3","language":"und"}],"entries":[{"type":"related","terms":[{"type":"text","text":"tests","language":"und","labels":[{"text":"plural"}]}]},{"type":"meaning","terms":[{"type":"text","text":"A procedure intended to establish the quality, performance, or reliability of something, esp. before it is taken into widespread use","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"no sparking was visible during the \x3cem\x3etests\x3c/em\x3e","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"A short written or spoken examination of a person\x27s proficiency or knowledge","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"a spelling \x3cem\x3etest\x3c/em\x3e","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"An event or situation that reveals the strength or quality of someone or something by putting them under strain","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"this is the first serious \x3cem\x3etest\x3c/em\x3e of the peace agreement","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"An examination of part of the body or a body fluid for medical purposes, esp. by means of a chemical or mechanical procedure rather than simple inspection","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"a \x3cem\x3etest\x3c/em\x3e for HIV","language":"en"}]},{"type":"example","terms":[{"type":"text","text":"eye \x3cem\x3etests\x3c/em\x3e","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"A procedure employed to identify a substance or to reveal the presence or absence of a constituent within a substance","language":"en"}]},{"type":"meaning","terms":[{"type":"text","text":"The result of a medical examination or analytical procedure","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"a positive \x3cem\x3etest\x3c/em\x3e for protein","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"A means of establishing whether an action, item, or situation is an instance of a specified quality, esp. one held to be undesirable","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"a statutory \x3cem\x3etest\x3c/em\x3e of obscenity","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"A movable hearth in a reverberating furnace, used for separating gold or silver from lead","language":"en"}]}]},{"type":"headword","terms":[{"type":"text","text":"test","language":"en","labels":[{"text":"Verb","title":"Part-of-speech"}]},{"type":"phonetic","text":"/test/","language":"und"},{"type":"sound","text":"http://www.gstatic.com/dictionary/static/sounds/de/0/test.mp3","language":"und"}],"entries":[{"type":"related","terms":[{"type":"text","text":"tests","language":"und","labels":[{"text":"3rd person singular present"}]},{"type":"text","text":"tested","language":"und","labels":[{"text":"past participle"}]},{"type":"text","text":"testing","language":"und","labels":[{"text":"present participle"}]},{"type":"text","text":"tested","language":"und","labels":[{"text":"past tense"}]}]},{"type":"meaning","terms":[{"type":"text","text":"Take measures to check the quality, performance, or reliability of (something), esp. before putting it into widespread use or practice","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"this range has not been \x3cem\x3etested\x3c/em\x3e on animals","language":"en"}]},{"type":"example","terms":[{"type":"text","text":"the \x3cem\x3etesting\x3c/em\x3e and developing of prototypes","language":"en"}]},{"type":"example","terms":[{"type":"text","text":"a useful way to \x3cb\x3e\x3cem\x3etest\x3c/em\x3e out\x3c/b\x3e ideas before implementation","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"Reveal the strengths or capabilities of (someone or something) by putting them under strain","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"such behavior would severely \x3cem\x3etest\x3c/em\x3e any marriage","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"Give (someone) a short written or oral examination of their proficiency or knowledge","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"all children are \x3cem\x3etested\x3c/em\x3e at eleven","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"Judge or measure (someone\x27s proficiency or knowledge) by means of such an examination","language":"en"}]},{"type":"meaning","terms":[{"type":"text","text":"Carry out a medical \x3cem\x3etest\x3c/em\x3e on (a person, a part of the body, or a body fluid)","language":"en"}]},{"type":"meaning","terms":[{"type":"text","text":"Produce a specified result in a medical \x3cem\x3etest\x3c/em\x3e, esp. a drug \x3cem\x3etest\x3c/em\x3e or AIDS \x3cem\x3etest\x3c/em\x3e","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"he \x3cb\x3e\x3cem\x3etested\x3c/em\x3e positive\x3c/b\x3e for steroids during the race","language":"en"}]}]},{"type":"meaning","terms":[{"type":"text","text":"Examine (a substance) by means of a reagent","language":"en"}]},{"type":"meaning","terms":[{"type":"text","text":"Touch or taste (something) to check that it is acceptable before proceeding further","language":"en"}],"entries":[{"type":"example","terms":[{"type":"text","text":"she \x3cem\x3etested\x3c/em\x3e the water with the tip of her elbow","language":"en"}]}]}]},{"type":"headword","terms":[{"type":"text","text":"test","language":"en","labels":[{"text":"Noun","title":"Part-of-speech"}]},{"type":"sound","text":"http://www.gstatic.com/dictionary/static/sounds/de/0/test.mp3","language":"und"}],"entries":[{"type":"related","terms":[{"type":"text","text":"tests","language":"und","labels":[{"text":"plural"}]}]},{"type":"meaning","terms":[{"type":"text","text":"The shell or integument of some invertebrates and protozoans, esp. the chalky shell of a foraminiferan or the tough outer layer of a tunicate","language":"en"}]}]}]}

您的JSON格式不正确。请与-

然后试试这个:

    NSString *strResponse = [request responseString];
    SBJSON *objJSONParser = [[SBJSON alloc] init];
    NSDictionary *dictData = [objJSONParser objectWithString:strResponse error:nil];

     NSDictionary *dictResult = [dictData objectForKey: @"response"];
     NSString *strQuery=[dictResult objectForKey:@"query"];.......... with your Key..
然后得到这样的数组

     NSArray *arrPrimaries=(NSArray *)[dictData objectForKey:@"primaries"];

您的JSON格式不正确。请与-

然后试试这个:

    NSString *strResponse = [request responseString];
    SBJSON *objJSONParser = [[SBJSON alloc] init];
    NSDictionary *dictData = [objJSONParser objectWithString:strResponse error:nil];

     NSDictionary *dictResult = [dictData objectForKey: @"response"];
     NSString *strQuery=[dictResult objectForKey:@"query"];.......... with your Key..
然后得到这样的数组

     NSArray *arrPrimaries=(NSArray *)[dictData objectForKey:@"primaries"];

对于这个问题有一个特别的解决方案。尝试从响应的开头剥离
dict_api.callbacks.id100(
),从响应的结尾剥离
,200,null)
。比如:

responseString = [responseString componentsSeparatedByString:@"dict_api.callbacks.id100("][1];
responseString = [responseString componentsSeparatedByString:@",200,null)"][0];

SBJSON *objJSONParser = [[SBJSON alloc] init];
NSDictionary *dictData = [objJSONParser objectWithString:strResponse error:nil];
// ... so on

请注意,这是一个临时解决方案,可能不适用于任何其他响应。按照@ararog的建议:查找API以获得仅JSON的响应。

对于这个问题有一个特别的解决方案。尝试从响应的开头剥离
dict_api.callbacks.id100(
),从响应的结尾剥离
,200,null)
。比如:

responseString = [responseString componentsSeparatedByString:@"dict_api.callbacks.id100("][1];
responseString = [responseString componentsSeparatedByString:@",200,null)"][0];

SBJSON *objJSONParser = [[SBJSON alloc] init];
NSDictionary *dictData = [objJSONParser objectWithString:strResponse error:nil];
// ... so on

请注意,这是一个临时解决方案,可能不适用于任何其他响应。按照@ararog:find-API的建议获取仅JSON的响应。

我试图删除回调参数,但它给了我一个错误。如果没有回调参数,它永远不会处理我的请求。有没有其他方法可以做到这一点?当我试图避免回调参数时,它会给我空响应。我试图删除回调参数,但它会给我一个错误。如果没有回调参数,它永远不会处理我的请求。有没有其他方法可以做到这一点?当我试图避免回调参数时,它会给我空响应。Thanx Vova。但我已经这样做了,现在我能够得到json格式的响应。但有时它还是会给我一本字典,有时它还能正常工作。这是因为它是一个临时解决方案吗?我无法避免回调参数。我该怎么办?当我试图避免回调参数时,它会给我空响应。@user2063425,可能是的,因为响应可能会不时变化,所以这个解决方法不起作用。我想,我遇到了确切的问题。正如Samir所说,我的json响应是无效的。它包含一些正则表达式类型值,如“\x3cem\x3e”。我不知道为什么它被用来做什么?但它确实存在,不允许json解析器解析json字符串。你甚至可以在上面给出的回答中检查它。但我已经这样做了,现在我能够得到json格式的响应。但有时它还是会给我一本字典,有时它还能正常工作。这是因为它是一个临时解决方案吗?我无法避免回调参数。我该怎么办?当我试图避免回调参数时,它会给我空响应。@user2063425,可能是的,因为响应可能会不时变化,所以这个解决方法不起作用。我想,我遇到了确切的问题。正如Samir所说,我的json响应是无效的。它包含一些正则表达式类型值,如“\x3cem\x3e”。我不知道为什么它被用来做什么?但它确实存在,不允许json解析器解析json字符串。你甚至可以在上面给出的回答中检查它。是的。。。。萨米尔。你是对的。我的jsonp响应无效。它包含一些json解析器无法解析的字符串。但每一个都很难更换。我能做什么?是的。。。。萨米尔。你是对的。我的jsonp响应无效。它包含一些json解析器无法解析的字符串。但每一个都很难更换。我能做什么。