Docs → jsonToToon()
🔄
jsonToToon()
Convert JavaScript objects to TOON format
This function inspects your JavaScript object and automatically detects the type of each value (null, string, number, boolean, array, object). It then generates the appropriate TOON-formatted string.
Type Detection Rules
null→ nlstring→ snumber→ nboolean→ bArray→ aObject→ j (JSON)
Example
JavaScript Input
const obj = { device_id: "DEVICE_PRO_01", battery: 87, temperature: 36.7, is_active: true, last_error: null, location: { lat: 12.9716, lng: 77.5946 }, tags: ["iot", "health", "tracker"] }; const toon = jsonToToon(obj);
TOON Output
device_id[1]{0:s}: DEVICE_PRO_01 battery[1]{0:n}: 87 temperature[1]{0:n}: 36.7 is_active[1]{0:b}: true last_error[1]{0:nl}: null location[1]{0:j}: {"lat":12.9716,"lng":77.5946} tags[1]{0:a}: ["iot","health","tracker"]