React Native JSONSerialization

I have a NSDictionary

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

and I need to pass this to react native as a launchOptions which accept JSON to be in this format. (The Quotes and = replaced with : etc )

  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": "notknown@whatever.com",
           "telephone": "18437584",
           "mobile": null,
           "smsAlert": null,
           "county": "Dublin",
           "country": "Ireland",
           "websiteAddress": "www.example.com"
       },

What is the best way to transform my dictionary so that react native accepts it?

Set address as a const or var and label the rest of the code in a format where it has these same numbers equal to each other, but in the const format. For example:

    const address =     {
            address1: {
  }
}

Comments

Popular posts from this blog

Meaning of `{}` for return expression

Get current scroll position of ScrollView in React Native

flutter websocket connection issue