NSJSONSerialization JSONObjectWithData:data 30C

NSData *data = [parameterString dataUsingEncoding:NSUTF8StringEncoding];
parameters = [NSJSONSerialization JSONObjectWithData:data
options:NSJSONReadingMutableContainers
error:&error];

在xcode里面,用的是object-c语言,这个有什么错误吗。各位帮帮忙

2个回答

不知道你是要 string转data,还是data转string?

数据转换要用try catch捕获异常,因为数据可能转换会失败,比如数据格式等不正确。做好错误处理

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
使用NSJSONSerialization JSONObjectWithData:读取数据时发生错误
[code=objc]NSDictionary *projectPositionJSON = [NSJSONSerialization JSONObjectWithData:[aDict objectForKey:@"Position"]rn options:NSJSONReadingAllowFragmentsrn error:nil];[/code]用上面的代码从aDict里读出位置数据,aDict是一个NSMutableDictionary,从数据库中读取得到rn原本是没有问题的,但当我往数据库里新加了一条测试数据的时候,这句代码就会报错:rn2019-01-16 21:51:50.785 IntelligentPlanningMobile[2511:692690] -[__NSCFString bytes]: unrecognized selector sent to instance 0x18964400rn2019-01-16 21:51:50.787 IntelligentPlanningMobile[2511:692690] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString bytes]: unrecognized selector sent to instance 0x18964400'rn数据库里的数据长这样:rn[img=https://img-bbs.csdn.net/upload/201901/16/1547646858_860356.png][/img]rn最后那条“瞎编的”就是我新加的数据,除了id基本上都是复制的上一条的内容,读到这一条的时候就会报错rn打了断点之后发现,在读取其他数据的时候“position”对应的key值是一个NSConcretemMutableData类型的数据,而“瞎编的”这条是NSCFString类型的,(如下图)我怀疑可能是这个原因,但为什么到这一条的时候数据类型就不一样了?[img=https://img-bbs.csdn.net/upload/201901/16/1547647220_927301.png][/img][img=https://img-bbs.csdn.net/upload/201901/16/1547647221_181687.png][/img]rn
NSJSONSerialization 解析数据 ,进行数据交换。
数据解析有名的第三方框架有SBJSON和JSONKit ,但是我项目中酒简简单单的使用了苹果自带的NSJSONSerialization来进行数据解析。   1  常用的方法有两个 [NSJSONSerialization JSONObjectWithData: options: error:]json数据转成OC对象, :NSData类型,通过  
iOS NSJSONSerialization 解析
ios5中apple增加了解析JSON的api——NSJSONSerialization。网上已经有人做过测试,NSJSONSerialization在效率上完胜SBJSON、TouchJSON、YAJL、JSONKit、NextiveJson。详情见这里。既然apple为我们提供了这么良好的工具,我们没理由不用吧。NSJSONSerialization提供了将JSON数据转换为Foundation对象(一般都是NSDictionary和NSArray)和Foundation对象转换为JSON数据(可以通过调用isValidJSONObject来判断Foundation对象是否可以转换为JSON数据)。
苹果开发 笔记(77)NSJSONSerialization
NSJSONSerialization 是解析json的自带的ios 类,使用它可以解析json 的信息。除了读取xml外,json也是比较常用的一些数据操作。之前用了一下,现在记录一下。下面记录一下json的页面信息,以获取天气的信息json来解析一下。{"weatherinfo":{"city":"北京","cityid":"101010100","temp":"9","WD":"西南风","
NSJSONSerialization ios5 JSON API
NSJSONSerialization ios5 JSON API
坑爹错误——NSJSONSerialization 反序列化失败
解析数据报如下错误: Error Domain=NSCocoaErrorDomain Code=3840 “No string key for value in object around character 1.” UserInfo={NSDebugDescription=No string key for value in object around character
xcode自带的NSJSONSerialization解析中文就会失败
NSDictionary *rspDic = [NSJSONSerialization JSONObjectWithData : data                                                        options : NSJSONReadingMutableContainers                                 
iOS网络开发——JSON数据解码(使用NSJSONSerialization)
下面我们通过一个案例MyNotes学习一下NSJSONSerialization的用法。这里重新设计数据结构为JSON格式, 其中备忘录信息Notes.json文件的内容如下: {"ResultCode":0,"Record":[ {"ID":"1","CDate":"2012-12-23","Content":"发布iOSBook0","UserID":"tony"}, {"ID":"2",
NSJSONSerialization使用——json格式字符串与dict字典的相互转换
json格式字符串与dict字典的相互转换,可以使用系统自带的NSJSONSerialization类。 当然也可以使用第三框架进行操作,如JSONKit(https://github.com/johnezang/JSONKit)。 // dict字典转json字符串 - (NSString *)jsonStringWithDictionary:(NSDictionary *)dict
Swift中NSJSONSerialization类抛出异常的处理写法
Swift虽然和OC在实现功能上用到的几乎是的类的属性和方法,但是在写法上就存在着巨大的区别,其中就有抛出异常的处理写法上,下面就是它的正确写法(1)Swift写法 // 抛出异常 do { let dic:NSDictionary = try NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOption
ios的NSJSONSerialization解析json数字时的错误
写了近两年的android 自认为技术成长还不错 最近却被老大说看着没什么进步 没什么进步。。。好吧 所以要求来写ios了 把安卓端上的图片处理移植到苹果上 其实不大想写 可是这小公司实在没什么的了 废话了 OC的NSJSONSerialization在解析json时,遇到数字,貌似有个转换错误和精度问题 现象 NSUserDefaults *userDefaults = [NSU
swift:使用NSJSONSerialization解析本地json数据文件(代码详细注释)
xcode version7.2  1 创建工程:打开xcode 选择ios平台下的sing view application ,选择swift语言,创建工程 2 在项目中新建data.json文件,用于存储json格式的文件 3 data.json文件的内容是(ps:这里的数据是找的网上的json数据) {     "name": "中国",     "pro
使用NSJSONSerialization解析从网络中获取的数据
处理从网络中获取的Json数据,现在以某网站的的天气数据为例,代码如下: - (void)viewDidLoad {     [super viewDidLoad];     [self loadMyJsonData];     // Do any additional setup after loading the view, typically from a nib
Drupal data Drupal data
Drupal dataDrupal data
/data/data/和手机拍照
/data/data/应用包名/files=AppContext.getInstance().getFilesDir().getPath(); 因为用的是getFilesDir获取的,所以此路径应是手机内部存储卡路径 手机拍照时候不能把照片存在/data/data路径,否则会出现异常情况
有关android /data/data/ [
把asset下的数据库xx.db复制到/data/data/package_name/xx.db下,无法复制啊 !!什么问题 ?? 应该不用root吧? 这个目录本身是属于本应用程序的!理论上来说本应用程序是可以访问!rnprivate SQLiteDatabase openDataBase(String path) rnLog.e("SQLite exist:", "" + new File(path).exists() + "::" + path); rn// TODO Auto-generated method stub rntry rnFile file = new File(path); rnif (!file.exists()) // 判断数据库是否存在,若不存在执行导入操作,否则直接打开数据库 rn// InputStream ins = context.getResources().openRawResource( rn// R.raw.ty_city); rnfile.createNewFile(); rnInputStream ins = context.getAssets().open("Chinacity.db"); rnFileOutputStream fos = new FileOutputStream(path); rnbyte[] buffer = new byte[BUFFER_SIZE]; rnint count = 0; rnwhile ((count = ins.read(buffer)) > 0) rnfos.write(buffer, 0, count); rnLog.e("buffer...", "" + count); rn rnfos.close(); rnins.close(); rn rnSQLiteDatabase sqLiteDatabase = context.openOrCreateDatabase( rnDB_NAME, 0, null); rnreturn sqLiteDatabase; rn catch (FileNotFoundException ffe) rnffe.printStackTrace(); rnLog.e("DataBaseFile:", "file can't find"); rn catch (IOException ioe) rn// TODO: handle exception rnLog.e("IOException", ioe.getMessage()); rnioe.printStackTrace(); rn rnreturn null; rnrn报错rnrnjava.io.IOException: open failed: ENOENT (No such file or directory)//file.createNewFile(); rn
data
string txtConn ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\StudentI.mdb";rn OleDbConnection conn = new OleDbConnection(txtConn);//建立连接rn string txtCommand = "SELECT * FROM student";rn OleDbDataAdapter da = new OleDbDataAdapter(txtCommand, conn);rn DataSet DataSet1 = new DataSet();rn da.Fill(DataSet1, "MyTable");rn rn DataRow dr=DataSet1.Tables["student"].NewRow();//为什么到这句提示我“未将对象引用设置到对象的实例”。rn dr["xh"]=133;rn dr["xm"]="鲁豫";rn dr["xb"] = "女";rnrn if (DataSet1.HasChanges())rn da.Update(DataSet1);//更新数据库rn MessageBox.Show("追加完成");rnrnrn为啥这样提示我出错呢?rnrn另外,我现在搞不明白 OleDbCommand 的方式对数据库操作是不是数据库一直连接着?而dataset是将数据读了以后就断开了?rnrn如果我做一个小的C/S数据库管理软件,应该用那种方式比较方便呢?rnrnrn对比使用向导方式导入的数据库,是不是向导方式在执行速度上比较慢?
data()
rn照理说现在应该是2012-05-26-21-17的。。为啥是下面时间?!难道是时区错误?再哪修改时区!rn2012-05-26 13:05:32
长data变窄data
注重基础函数的应用,用了两个比较常用的package library(plyr) library(rlist) A <- data.frame(a = c(rep("A",3), rep("B",3), rep("C",4)), b = c(1,2,3,4,5,6,...
Data, Data, Everywhere
You've been asked to make a simple text-based database that can store any number of fields associated with records. IDs can contain letters, numbers, dashes (-), and slashes (/), and are case-sensitive. The standard data format for input and output is:nrecord-idnfield-idnsome data herenterminated withna single periodn.nnThere are NO blank lines between entries.nnSome commands have lists of record IDs or field IDs. These are comma-separated lists of IDs (no spaces) that specify the order of the output. * can be specified instead of a list of IDs. If * is specified for the record IDs, treat it as a comma-separated lexicographically sorted list of all the record IDs with at least one field in the database. If * is specified for the field IDs, treat it as a comma-separated lexicographically sorted list of all the field IDs defined by at least one record in the database.nnThe list of commands and their parameters follows:nnCommand Descriptionnshow For the specified records, display the values of the specified fields. This command takes two parameters, a list of record IDs and a list of field names. Both are comma-separated lists (no spaces) which specify which entries to display and in what order to display them. Output should follow the standard entry format and should be terminated by a line containing a single asterisk.nIf a record does not have data for a field, then display the following entry for that record:nnrecord-idnfield-namenNO DATAn.nnrem The program should ignore the text.nappend Read in text and add it to the end of the specified entry, creating the entry if necessary. Input is terminated with a single period.ndelete For the specified records, delete the values of the specified fields. This command takes two parameters, a list of record IDs and a list of field names.ndone Stop processing this list of commands.nnInputnnRead commands from the input, one command per line. There will be at most 50,000 lines in the input (including any read files), a mix of commands and data. IDs will be at most 64 characters long. There will be at most 10,000 field IDs and 10,000 record IDs defined at any given time, although more may be defined after the old IDs have been deleted. Each line will be at most 255 characters long. Record field data will be at most 2,000 lines long.nnnOutputnnnOnly the show command produces output. Print the output in the standard data format to the standard output stream.nnThe program should finish the given input within 60 seconds.nnnSample Inputnnappend team-bar prob-bn1400 Accepted.n.nappend team-foo prob-an1305 Wrong answer.n.nshow team-foo,team-bar *nappend team-foo prob-an1402 Accepted.n.nrem Hmm...ndelete team-bar *n.nshow * *ndonennnSample Outputnnteam-foonprob-an1305 Wrong answer.n.nteam-foonprob-bnNO DATAn.nteam-barnprob-anNO DATAn.nteam-barnprob-bn1400 Accepted.n.n*nteam-foonprob-an1305 Wrong answer.n1402 Accepted.n.n*
Data Preparation for Data Mining
一本非常不错的数据挖掘入门书籍。比较清晰的说明了数据挖掘部分的工作,而这也正是行业机器学习模型开发中最基本、最重要的部分。
Python for Data Analysis_ Data
Python for Data Analysis_ Data 第二版 英文版 Python3实现 代码部分有问题,格式不对,不要下载了,
data mining data processing
介绍数据预处理的PPT,英文版,包括数据预处理的目的,数据清洗、数据转换、数据规约等
Sending data is not Sending data
rn[code=SQL]rnmysql> SHOW PROFILES;rn+----------+------------+------------------------------------------------------------------------------------------------------------------------------+rn| Query_ID | Duration | Query |rn+----------+------------+------------------------------------------------------------------------------------------------------------------------------+rn| 5 | 0.98439500 | SELECT DISTINCT smw_namespace, smw_title, smw_iw FROM `smw_rels2`,`smw_ids` WHERE p_id='8979' AND o_id=smw_id LIMIT 1000 |rn| 6 | 0.23709100 | SELECT smw_namespace, smw_title, smw_iw FROM `smw_rels2`,`smw_ids` WHERE p_id='8979' AND o_id=smw_id LIMIT 1000 |rn+----------+------------+------------------------------------------------------------------------------------------------------------------------------+rn6 rows in set (0.00 sec)rn rnmysql> SHOW PROFILE FOR QUERY 6;rn+--------------------------------+----------+rn| Status | Duration |rn+--------------------------------+----------+rn| starting | 0.000013 |rn| checking query cache for query | 0.000056 |rn| Opening tables | 0.000028 |rn| System lock | 0.000017 |rn| Table lock | 0.000047 |rn| init | 0.000017 |rn| optimizing | 0.000018 |rn| statistics | 0.000261 |rn| preparing | 0.000014 |rn| executing | 0.000002 |rn| [color=#FF0000]Sending data | 0.236548 [/color]|rn| end | 0.000008 |rn| query end | 0.000004 |rn| freeing items | 0.000040 |rn| storing result in query cache | 0.000012 |rn| logging slow query | 0.000002 |rn| cleaning up | 0.000004 |rn+--------------------------------+----------+rn17 rows in set (0.00 sec)rn rnmysql> SHOW PROFILE FOR QUERY 5;rn+--------------------------------+----------+rn| Status | Duration |rn+--------------------------------+----------+rn| starting | 0.000012 |rn| checking query cache for query | 0.000061 |rn| Opening tables | 0.000020 |rn| System lock | 0.000015 |rn| Table lock | 0.000045 |rn| init | 0.000016 |rn| optimizing | 0.000014 |rn| statistics | 0.000229 |rn| preparing | 0.000013 |rn| Creating tmp table | 0.000038 |rn| executing | 0.000003 |rn| Copying to tmp table | 0.983473 |rn| [color=#FF0000]Sending data | 0.000351[/color] |rn| end | 0.000004 |rn| removing tmp table | 0.000048 |rn| end | 0.000004 |rn| query end | 0.000004 |rn| freeing items | 0.000025 |rn| storing result in query cache | 0.000012 |rn| logging slow query | 0.000001 |rn| cleaning up | 0.000007 |rn+--------------------------------+----------+rn21 rows in set (0.00 sec)rn rn[/code]rn第5,6条,只有一个DISTINCT不一样。5用到了临时表进行数据去重。rn获取的数据都是一样的,SENDING DATA如果是发送数据到客户端这样话,就没办法解释为什么5,6的SENDING DATA时间相差这么巨大。rnrn往上再看一布操作耗时比较长的过程都是在executing后面。rn看到一个外国人问的这个问题,他说SENDING DATA后面的时间其实是executing的。rnrn从上面看来,没个参数项后面的值,代表的是此参数项前面那个参数项的执行时间,这样理解才说得通。rnrn请斑竹指正。rn
关于data,data?段地址
window程序中平时一般的代码的起始地址应该都是0040100开始的吧,这是在链接的时候进行设置的rnrn那data,const,data?段的呢,也是在链接的时候就设置好了吗?rnrn
data warehouse & data mining
这个从哪开始入手,有什么推荐书籍?我用不用学统计学什么的?rn本人专业计算机 数据库只接触过SQLSevere 2000 & 2005rn请教过来人 ,感谢了~~~~
android /data/data
很多人都找不到 data/data 这个路径,根据我的理解,他是用户不可见的。所谓不可见,是指在工作目录及Eclipse下是不可见的。rnrn当然,你还是可以通过很多方式,看到。例如:File Explorer 试图下可以看到;若果你是在Linux 下,更方便,进入源码,rnrn输入命令: adb shell ---> ls ---> data/data 就可以看到了。
.data ?
汇编里面 数据段rnrn.data? 后面加了个问好后,用ollydebug 调试的时候,为什么没有 数据,常用寄存器不会因为数据的变动而变动。。内存里也没有数据啊?rnrn。。。。rn那 加了 ? 以后该怎么调试程序, 难道先 不加问号,然后调试好了再加上问号。。。。?
查看/data/data下的数据库文件
1、进入adb shell 模式    adb shell 2、获得所有root权限 su   3、先把文件夹权限全部打开 chmod 777 /data/   4、给里边的db文件权限设置成可读可写可操作 chmod 777 /data/data/(项目全包名)/databases/xxx.db   5、cd命令进入db文件所在目录:     cd /data/d...
data analysis and data mining
数据分析数据挖掘相关的英文书籍, 很好的入门书籍, 看完可以有一个大概的了解
Data Analytics and Big Data
The main purpose of this book is to investigate, explore and describe approaches and methods to facilitate data understanding through analytics solutions based on its principles, concepts and applications. But analyzing data is also about involving the use of software. For this, and in order to cover some aspect of data analytics, this book uses software (Excel, SPSS, Python, etc) which can help readers to better understand the analytics process in simple terms and supporting useful methods in its application.
Data preparation for data mining.pdf
数据挖掘中的数据预处理 data preparation for data mining
data???
我用access做的数据库--data识别不了..这怎么办??
Fun( Data &data ) 与 Fun ( Data data )有什么不同
RT.....rn敬请解惑......
Data Mining with Big Data
This paper presents a HACE theorem that characterizes the features of the Big Data revolution, and proposes a Big Data processing model, from the data mining perspective. This data-driven model involves demand-driven aggregation of information sources, mining and analysis, user interest modeling, and security and privacy considerations. We analyze the challenging issues in the data-driven model and also in the Big Data revolution.
OC 在NSJSONSerialization 过滤JSON解析不了的掉特殊字符
- (NSString *)stringConvert:(NSString *)string{     //过滤不能打印的ASCII码     NSMutableString *str = [NSMutableString stringWithString:string];     for (int i = 0; i length; i++) {         int
ios进行restful接口调用和json数据利用自带NSJSONSerialization进行数据解析
ios中进行request进行restful的post方式接口的调用,并利自身的json数据的解析方法进行数据的获取
建立网络连接的基本步骤及NSJSONSerialization(苹果自带)——JSON解析
什么是JSON JSON是一种轻量级的数据格式,一般用于数据交互 服务器返回给客户端的数据,一般都是JSON格式或者XML格式(文件下载除外) NSJSONSerialization的常见方法 JSON数据 ——>OC对象(JSON解析) + (id)JSONObjectWithData:(NSData*)data options:(NSJSONReadingOptions)
文件存取 data/data/包名/files
//把message存到 data/data/包名/files 目录下的xxx.txt文件下  public void saveFileByActivity(String message){         try {             FileOutputStream outStream;             outStream = this.openFileOutput("x
没有Tasks--Import Data和Export Data
SQL server2005开发版本安装后,在数据库节点处点右击菜单时没有Tasks--Import Data和Export Data这两项?请问是为什么?谢谢。
相关热词 c# 去空格去转义符 c#用户登录窗体代码 c# 流 c# linux 可视化 c# mvc 返回图片 c# 像素空间 c# 日期 最后一天 c#字典序排序 c# 截屏取色 c#中的哪些属于托管机制