Thank you for enlightening me and correcting my json vocab. Rather than look into old tools for the reason this falls back to stem id, let me present you with a much better json library instead
local JSON = require "JSON"
json_stanza = JSON:object("json-l0_object0", JSON:object("json-l1_string0", "blah-0", "json-l1_string1", "blah-1", "json-l1_array0", JSON:array(0,1,2,3)), "json-l0_string0", "blah-0");
print(json_stanza, #json_stanza);
print(json_stanza["json-l0_object0"], #json_stanza["json-l0_object0"])
print(json_stanza:len())
for i = 0, #json_stanza["json-l0_object0"]["json-l1_array0"]-1 do
print(json_stanza["json-l0_object0"]["json-l1_array0"][i])
end
print(json_stanza:tojson())
print(json_stanza:tolua())
print(json_stanza:tobash()) --> output in native Bash 4+ format
output
object: 0x5d5b79e05850 2
object: 0x5d5b79dfcec0 3
130
0
1
2
3
{"json-l0_object0":{"json-l1_string0":"blah-0","json-l1_string1":"blah-1","json-l1_array0":[0,1,2,3]},"json-l0_string0":"blah-0"}
{json-l0_object0={json-l1_string0="blah-0",json-l1_string1="blah-1",json-l1_array0={0,1,2,3}},json-l0_string0="blah-0"}
([json-l0_object0]="([json-l1_string0]="blah-0" [json-l1_string1]="blah-1" [json-l1_array0]="(0 1 2 3)") [json-l0_string0]="blah-0")
api ref
EDIT
i noticed something writing the above script, i think it may be the root of your issue.
your string keys contian special characters, specifically "-" ... lua can not handle these keys in normal string key syntax ...ie some-value.another_value, the interperter chokes on the - so you must use the literal string syntax
json_stanza["json-l0_object0"] works
json_stanza.json-l0_object0 fails on -
now i think jshn .sh does the same only for a different reason .. While Lua chokes on unquoted hyphens because it sees them as the subtraction operator, jshn.sh chokes because it uses the JSON keys to dynamically generate shell variable names, and hyphens are illegal in Bash/POSIX variable names.
so i think if you change
"json-l0_object0" to "json_l0_object0"
it will work as expected ??