如何在ios中解析资源文件夹中的json文件
我从本地组文件夹解析JSON文件它工作正常,但我使用资源组文件夹它不解析JSON文件,下面是我的代码 我使用loacl组的路径是如何在ios中解析资源文件夹中的json文件,ios,json,resources,Ios,Json,Resources,我从本地组文件夹解析JSON文件它工作正常,但我使用资源组文件夹它不解析JSON文件,下面是我的代码 我使用loacl组的路径是 NSString *filePath = [[NSBundle mainBundle] pathForResource:@"nbg_ov_t_l_2_2" ofType:@"json"]; 这里不是我用于资源文件夹的这一行,而是我的资源文件夹(蓝色文件夹) 这是我的JSON文件 { "background_image":false, "template_orient
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"nbg_ov_t_l_2_2" ofType:@"json"];
这里不是我用于资源文件夹的这一行,而是我的资源文件夹(蓝色文件夹)
这是我的JSON文件
{
"background_image":false,
"template_orientation":"landscape",
"background_colour":{
"red":202,
"green":150,
"blue":100,
"alpha":50
},
"images":[
{
"background_status":false,
"tilt_angle":0,
"orientation":"portrait",
"overlay":false,
"rect":
{
"x":0,
"y":0,
"width":100,
"height":100
}
},
{
"background_status":false,
"tilt_angle":25,
"orientation":"landscape",
"overlay":true,
"rect":
{
"x":25,
"y":60,
"width":30,
"height":50
}
}
]
}
我还有另一个疑问,如何从本地获取一些json文件(也就是说,我有10个json文件意味着我只想获取三个,我只解析这三个)以及如何解析它。
帮帮我…那么您尝试从哪个路径加载JSON?是相同的JSON吗?返回了哪些错误?如果我使用文件表单组文件夹,它可以工作,但我在资源组中使用相同的文件,它不会提供路径null。路径null是我的错误,并且您检查了文件夹是否已添加到目标,因此在生成期间它将被复制到应用程序?
{
"background_image":false,
"template_orientation":"landscape",
"background_colour":{
"red":202,
"green":150,
"blue":100,
"alpha":50
},
"images":[
{
"background_status":false,
"tilt_angle":0,
"orientation":"portrait",
"overlay":false,
"rect":
{
"x":0,
"y":0,
"width":100,
"height":100
}
},
{
"background_status":false,
"tilt_angle":25,
"orientation":"landscape",
"overlay":true,
"rect":
{
"x":25,
"y":60,
"width":30,
"height":50
}
}
]
}