iOS SDK原生JSON解析
- (IBAction)touchReadButton:(id)sender
{
NSData *jsonData = [[NSData alloc] initWithContentsOfFile:JSON_PATH];
NSError *error = nil;
id jsonObject = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments error:&error;];
if (jsonObject != nil && error == nil)
{
NSLog(@"Successfully deserialized...");
if ([jsonObject isKindOfClass:[NSDictionary class]])
{
NSDictionary *deserializedDictionary = (NSDictionary *) jsonObject;
NSLog(@"Dersialized JSON Dictionary = %@", deserializedDictionary);
}
else if([jsonObject isKindOfClass:[NSArray class]])
{
NSArray *deserializedArray = (NSArray *)jsonObject;
NSLog(@"Dersialized JSON Array = %@", deserializedArray);
}
else
{
NSLog(@"An error happened while deserializing the JSON data.");
}
}
}
iOS SDK原生JSON解析的更多相关文章
- 原生JSON解析
原生JSON解析 JSONObject:JSON数据封装对象JSONArray:JSON数据封装数组 布局: <?xml version="1.0" encoding=&qu ...
- iOS开发系列-JSON解析
概述 JOSN是一种轻量级的数据格式,一般用于数据交互.服务器返回给客户端,一般都是JSON格式或者XML格式. JSON的格式: {"name" : "CoderHon ...
- iOS开发之JSON解析
JSON解析步骤: - (NSArray *)products { if (_products == nil) { //第一步:获取JSON文件的路径: NSString *path = [[NSBu ...
- .Net Core 3.0原生Json解析器
微软官方博客中描述了为什么构造了全新的Json解析器而不是继续使用行业准则Json.Net 微软博客地址:https://devblogs.microsoft.com/dotnet/try-the-n ...
- iOS原生JSON解析.
- (IBAction)accessInterfaceBtnPressed:(id)sender { NSError *error; NSString *URL=@"ht ...
- iOS 后台返回json解析出现的null的解决办法
在后台返回值为Null为空时,我们代码没有判断时,程序就会崩溃.当时一直很疑惑是为啥,后来发现是数据问题,由于服务器的数据库中有些字段为空,然后以Json形式返回给客户端时就会出现这样的数据.当我们通 ...
- IOS自带json解析类解析json
- (IBAction)test:(id)sender { NSString *result = @"{\"code\":\"S00000\",\&q ...
- iOS中处理json解析出现的null,nil的解决办法
最开始是使用的一个函数进行处理,代码如下: - (id) setNoNull:(id)aValue{ if (aValue == nil) { aValue = @"";//为nu ...
- iOS SDK中使用NSXMLParser解析XML(iphone网络篇三)
iOS SDK的NSXMLParser解析XML文档是事件驱动模式的,即采用SAX方式来解析XML格式文档.NSXMLParser在处理XML文档的过程中当遇到一些要素(元素.属性.CDATA块.评论 ...
随机推荐
- hdu 4405 Aeroplane chess(概率+dp)
Problem Description Hzz loves aeroplane chess very much. The chess map contains N+ grids labeled to ...
- C# 使用枚举获取对应的数组值时
using System; enum Move { walk, run } class Program { static float[] speedAry = { 50.0f, 200.0f }; p ...
- python高级编程之(类级):子类内建类型
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' #类级 #在2.2中,提出了类型(type0与类(class)统一( ...
- VirtualBox 扩展包卸载或安装失败(VERR_ALREADY_EXISTS)
最近在卸载VirtualBox出现了无法卸载的错误.提示为Failed to install the extension. The installer failed with exit code 1: ...
- Rhythmbox中文乱码解决的方法
转自:http://hi.baidu.com/morgensonne/item/3470aef58747abde6325d2d9 今天在网络上找到了一个比較好的解决Rhythmbox中文乱码的问题的方 ...
- CreateFile使用方法和样例
函数原型: HANDLE CreateFile( LPCTSTR lpFileName, //指向文件名称的指针 DWORD dwDesiredAccess, //訪问模式(写/读) DWORD dw ...
- javascript学习笔记(一)
学习书籍 Javascript高级程序设计 第3,4章 javascript数据类型 Undefined(undefined) Null(null,空指针) Boolean(true,false) N ...
- JS实现下拉框选中不同的项,对应显示不同的信息
实现的效果如下图: 页面代码 下拉框: <select id="select3" name="select3" onchange="showli ...
- poj1458 求最长公共子序列 经典DP
Common Subsequence Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 45763 Accepted: 18 ...
- poj1088 经典DP
滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 88296 Accepted: 33100 Description ...