React Native
React Native
JSON PathPrefix Example
Demonstrates the JSON object'sPathPrefix property.
Chilkat React Native Downloads
import { JsonObject } from '@chilkat/react-native'
function chilkatExample() {
const json = new JsonObject();
json.pathPrefix = 'company.billing.';
json.updateString('company_name', 'TechNova Solutions Inc.');
json.updateString('address_line_1', '123 Innovation Drive');
json.updateString('address_line_2', 'Suite 450');
json.updateString('city', 'Seattle');
json.updateString('state_province', 'WA');
json.updateString('postal_code', '98101');
json.updateString('country', 'USA');
json.emitCompact = false;
console.log(json.emit());
// Result:
// {
// "company": {
// "billing": {
// "company_name": "TechNova Solutions Inc.",
// "address_line_1": "123 Innovation Drive",
// "address_line_2": "Suite 450",
// "city": "Seattle",
// "state_province": "WA",
// "postal_code": "98101",
// "country": "USA"
// }
// }
// }
const city = json.stringOf('city');
console.log(`city = ${city}`);
}