Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.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
Ios Can';t在解析数据浏览器中上载JSON文件_Ios_Json_Parse Platform - Fatal编程技术网

Ios Can';t在解析数据浏览器中上载JSON文件

Ios Can';t在解析数据浏览器中上载JSON文件,ios,json,parse-platform,Ios,Json,Parse Platform,在数据浏览器的“文件列”中上载JSON文件时遇到问题 事实上,这一个被上传了 "foo" : [{ "bar": "test", "haha" : "lol" }] But this can't be uploaded { "foo" : [{ "bar": "test", "haha" : "lol" }] } 我需要第二种格式,因为该格式是有效的JSON格式,可以使用AFNetworking的JSON解析器进行解析 如果我使用第一种JSON格式,就会出现这个错误 Error: E

在数据浏览器的“文件列”中上载JSON文件时遇到问题

事实上,这一个被上传了

"foo" : [{ "bar": "test", "haha" : "lol" }]

But this can't be uploaded

{ "foo" : [{

 "bar": "test",
 "haha" : "lol"
}] }
我需要第二种格式,因为该格式是有效的JSON格式,可以使用
AFNetworking
的JSON解析器进行解析

如果我使用第一种JSON格式,就会出现这个错误

Error: Error Domain=NSCocoaErrorDomain Code=3840 "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=0x10d4301b0 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
编辑:这是请求的代码

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager GET:@"the link link to the JSON file" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

    //Do things here with the responseObject

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error: %@", error);

    }];

实际上,我正试图通过将JSON文件上传到数据浏览器中的文件对象来承载解析中的JSON文件。然后我要用AFN网络来获取它。根据我的观察,如果没有代码,具有有效结构的JSON文件是无法上传的,这真的很难评论。然而,我遇到Cocoa3840错误的次数是因为我的JSON结构不正确

这听起来很幼稚,但事实是:

[]表示数组{}表示字典

我猜,键“foo”与数组有关。当foo包含在{}中时,我认为foo是在NSDictionary中声明的;编码应该是这样的

NSMutableArray *local_array = @[@{@"bar":@"test",@"haha":@"lol"}]
NSDictionary *dict = @{@"foo":local_array};

在这个字典上尝试NSJSONSerialization,看看是否发生任何错误

我使用parse,但不确定File列是什么意思。也不确定上传JSON文件是什么意思。也许没关系。。。为什么不在发送到解析之前从AfNetworkInResult中去掉外部卷曲呢?请您用一些代码片段解释一下,您正在尝试…@danh实际上,我所说的文件列是解析数据浏览器中数据类型为“File”的列。我正在上传一个JSON文件。我导入它不是为了创建一个解析类。事实上,我正试图在Parse中托管JSON文件,然后使用afnetworking获取它。请参阅编辑的文章。从我观察到的情况来看,一个具有有效结构的JSON文件(通过jsonlint.com检查)没有上载到Parse Data browser的file Objective中。您是否正常启动了浏览器上的文件路径,并查看该文件是否存在?该文件没有上载。没有任何确认或其他信息。我尝试了其他类型的文件,我得到了成功上传对象的确认