जैसे ही मैंने एक JSON संसाधन मैं निम्नलिखित प्राप्त करने के लिए एक अनुरोध को ट्रिगर:AFNetworking 2.0 और प्रतिक्रिया क्रमबद्धता विकल्प
The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x1d87a2c0 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
समस्या मैं कहाँ स्थापित करना चाहिए कि AFNetworking 2.0 में टुकड़े के लिए अनुमति देते है?
अद्यतन:
मेरी कक्षा AFHTTPSessionManager की एक उप वर्ग है। मैंने पहले ही एक JSONResponseSerializer बनाया है और यह भी काम नहीं करता है।
इस प्रकारJSON लौटे जा रहा है:
[0] (null) @"NSDebugDescription" : @"Invalid value around character 0."
वेब सर्वर से प्रतिक्रिया:
[{"StoryId":1,"Title":"The big red dog","Abstract":"There was a big red dog and the dog was very big","IsFeatured":true}]
प्रतिसाद स्थिति से
[{"StoryId":1,"Title":"The big red dog","Abstract":"There was a big red dog and the dog was very big","IsFeatured":true}]
-(instancetype) initWithBaseURL:(NSURL *)url
{
NSURL *base = [NSURL URLWithString:@"URL to the web service that returns the json"];
self = [super initWithBaseURL:base];
AFJSONResponseSerializer *responseSerializer = [AFJSONResponseSerializer serializerWithReadingOptions:NSJSONReadingAllowFragments];
[self setResponseSerializer:responseSerializer];
return self;
}
त्रुटि दी पीछा कर रहा है वेब सर्वर:
HTTP/1.1 200 OK
Server: Microsoft-IIS/7.0
X-Powered-By: ASP.NET
Content-Type: application/json;charset=utf-8
X-AspNetMvc-Version: 3.0
Connection: close
Date: Mon, 28 Oct 2013 20:02:21 GMT
Content-Length: 121
Cache-Control: private
X-AspNet-Version: 4.0.30319
[{"StoryId":1,"Title":"The big red dog","Abstract":"There was a big red dog and the dog was very big","IsFeatured":true}]
यह वेब सर्वर की प्रतिक्रिया के साथ एक समस्या है, ** ** नहीं, AFNetworking के साथ। – akashivskyy
प्रतिक्रिया मान्य है! मैंने बस जेएसओएन को मान्य किया है और यह वैध JSON लौटाया जा रहा है। –
मैंने यह नहीं कहा कि यह * अमान्य * है। मैंने कहा कि * समस्या इसके कारण होती है *। JSON डेटा किसी सरणी या ऑब्जेक्ट के भीतर निहित होता है। @Wain सही है, आपको AFNetworking को बताना होगा कि JSON डेटा को पढ़ने के लिए कौन से विकल्प 'NSJSONSerialization' उपयोग करना चाहिए। – akashivskyy