Java Objective-C Json数据 [英] Java Objective-C Json data
本文介绍了Java Objective-C Json数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我也不太了解Objective-C中的代码行:
I have a little problem with understanding this too lines of code in Objective-C :
id jsonData;
NSInteger errorCode;
NSString* errorString;
errorCode = [jsonData sqlInt:@"error_code"];
errorString = [[jsonData objectForKey:@"error_string"] retain];
我试图找到一种方法来用Java执行相同的代码,这就是为什么我需要一点帮助来理解这段代码的原因. 预先谢谢!!!
I'm trying to find a way how to do the same code in Java,that's why I need a little help to understand this piece of code. Thanks in advance!!!
该代码与目标C中的代码相同吗? :
Is this code do the same as in Objective C? :
ErrorCode = new JSONObject();
ErrorCode.put("error_code", errorCode);
ErrorString = new JSONObject();
ErrorString.put("error_string", errorString);
推荐答案
尝试一下,
SBJSON *jsonData = [SBJSON alloc]init]; - Objective c
private JSONObject jObject; - Java
//您将获得一个JSON数据-目标C
// you get a JSON Data - Objective C
NSDictionary *errorString = [[jsonData objectForKey:@"error_string"] retain];
对于Java-
jObject = new JSONObject(errorString);
JSONArray menuitemArray = popupObject.getJSONArray("error_string");
String attributeValue = jObject.getString("value");
System.out.println(attributeValue);
这篇关于Java Objective-C Json数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文