Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
时点软件 冯成林 authored and 时点软件 冯成林 committed Jun 6, 2016
1 parent 2b61d2c commit bdeb651
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
Binary file not shown.
20 changes: 13 additions & 7 deletions Reflect/JsonConvert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,29 @@

import Foundation

let jsonStr = "{'name':'张三','age':32}"
let jsonStr = "{\"name\":null,\"age\":32}"


class CoachModel: Reflect {

var name: String?
var age: NSNumber?

static func parse(json: String?){
static func parse(){

let d = json?.dataUsingEncoding(NSUTF8StringEncoding)
let d = jsonStr.dataUsingEncoding(NSUTF8StringEncoding)

do{
try?{
let dict = NSJSONSerialization.JSONObjectWithData(d!, options: NSJSONReadingOptions.AllowFragments)
}
// id obj=[NSJSONSerialization JSONObjectWithData:correctStringData options:NSJSONReadingAllowFragments error:&error];
let dict = try? NSJSONSerialization.JSONObjectWithData(d!, options: NSJSONReadingOptions.AllowFragments)
let m = CoachModel.parse(dict: dict as! NSDictionary)

print(m)

} catch {


print("")

}


Expand Down
4 changes: 3 additions & 1 deletion Reflect/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ViewController: UIViewController {
// Student3.parse()
// Student4.parse()
// Student5.parse()
Student6.parse()
// Student6.parse()
// Student7.parse()
// Author.parse()
//
Expand All @@ -45,6 +45,8 @@ class ViewController: UIViewController {
// UserModel.parse()

// AppUserModel.parse()

CoachModel.parse()
}


Expand Down

0 comments on commit bdeb651

Please sign in to comment.