ChaiScript/unittests/object_from_json_5.chai
leftibot 362e93fb29
Fix #499: Add object_from_json, map_to_object, and object_to_map functions (#676)
Add object_from_json as a non-breaking alternative to from_json that returns
a Dynamic_Object instead of a Map, enabling dot-access syntax on JSON fields
(e.g. obj.name instead of obj["name"]). Nested JSON objects become nested
Dynamic_Objects. Also add map_to_object and object_to_map for Python-style
interconversion between maps and objects.

Co-authored-by: leftibot <leftibot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 15:44:04 -06:00

7 lines
214 B
ChaiScript

// object_from_json roundtrip through to_json
var json_str = "{\"key\":\"value\"}"
var obj = object_from_json(json_str)
var result = to_json(obj)
var obj2 = object_from_json(result)
assert_equal(obj2.key, "value")