2017-02-03 161 views
1

我有一个NSDictionary的阵营本地JSONSerialization

address =  { 
     address1 = "Ivy House"; 
     address2 = "Sandy Lane"; 
     city = Rush; 
     country = Ireland; 
     county = Dublin; 
     email = "[email protected]"; 
     mobile = "<null>"; 
     postCode = "<null>"; 
     smsAlert = "<null>"; 
     telephone = 18437584; 
     websiteAddress = "www.example.com"; 
    }; 

,我需要通过这个反应母语作为接受JSON一个launchOptions是这种格式。 (报价及=替换为:等)

RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 
                 moduleName:@"spotlight" 
               initialProperties:nil 
                launchOptions:launchOptions]; 

JSON

"address": 
     { 
      "address1": "Ivy House", 
      "address2": "Sandy Lane", 
      "city": "Rush", 
      "postCode": null, 
      "email": "[email protected]", 
      "telephone": "18437584", 
      "mobile": null, 
      "smsAlert": null, 
      "county": "Dublin", 
      "country": "Ireland", 
      "websiteAddress": "www.example.com" 
     }, 

什么是改变我的字典,使反应本土接受它的最佳方式?

+0

你是否看了[JSONSerialization(https://developer.apple.com/reference/foundation/jsonserialization)文档? –

回答

0

将地址设置为constvar,并将其余的代码标记为具有相同数字的格式,但格式为const格式。 例如:

const address =  { 
      address1: { 
    } 
}