China Naming Network - Ziwei Dou Shu - Can json parse jsp data in ios?

Can json parse jsp data in ios?

Can be parsed.

1. First, create a new project (be careful not to choose the ARC mechanism) and add the following controls:

2. the code in the 2.ViewController.h file:

(1) Use TouchJSon parsing method: (package to be imported: # import "TouchJSON/JSON/cjsondeserializer.h")

# Import? & ltui kit/ui kit . h & gt; ?

@ Interface? ViewController? :? UIViewController?

@ Property? (reserved,? Non-atomic)? IBOutlet? UITextView? * txtView?

-? (i action) btnpresstouchson: (id) sender; ?

-? (i action) btnpressbjson: (id) sender; ?

-? (I action)btnpressios 5 JSON:(id) sender; ?

-? (i action) btnpresssjsonkit: (id) sender; ?

@end?

3. the main code in the 3.ViewController.m file:

(1) Use TouchJSon parsing method: (package to be imported: # import "TouchJSON/JSON/cjsondeserializer.h")

//Analyze the weather in Beijing with TouchJson?

-? (i action) btnpresstouchson: (id) Sender? {?

//get the API interface?

NSURL? * Website? =? 【NSURL? URL with string:@ "/data/ 10 10 10 100 . html "]; ?

//Define a NSError object to capture error information?

NSError? * error; ?

NSString? *jsonString? =? 【NSString? stringwithcontentsourl:URL? Code: NSUTF8StringEncoding? Error: & Error]; ?

NSLog(@ " JSON string-& gt; %@ ",JSON string); ?

//Store the parsed content in a dictionary, with the encoding format of UTF8, so as to prevent garbled codes when fetching values?

NSDictionary? *rootDic? =? 【【CJSONDeserializer? Deserializer] Deserialization: [jsonString? data using encoding:nsu TF 8 string encoding]? Error: & Error]; ?

//Because the returned Json file has two layers, go to the second layer and put it in the dictionary?

NSDictionary? *weatherInfo? =? 【rootDic? objectForKey:@ " weather info "]; ?

NSLog(@ " weather info-& gt; %@ ",weather info); ?

//Print by value?

txtView.text? =? 【NSString? StringWithFormat:@ "What day is it today? %@? %@? %@? The weather condition in is:% @? %@?" ,【weatherInfo? objectForKey:@"date_y"],[weatherInfo? objectForKey:@"week"],[weatherInfo? objectForKey:@"city"],? 【weatherInfo? objectForKey:@ " weather 1 "],? 【weatherInfo? objectForKey:@ " temp 1 "]]; ?

}?