mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2026-04-30 19:09:26 +08:00
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>
4 lines
157 B
ChaiScript
4 lines
157 B
ChaiScript
// object_from_json: nested objects become nested Dynamic_Objects
|
|
var obj = object_from_json("{\"outer\":{\"inner\":42}}")
|
|
assert_equal(obj.outer.inner, 42)
|