2017-02-03 250 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: { 
    } 
}