Discussion:
[ast-developers] ksh beta read -m json parser bug also small print error
Jukka Inkeri
2014-10-13 14:04:38 UTC
Permalink
# [12] read: syntax error at line 39: `end of file' unexpected
read -m json person <<EOF
{
"first" : "My",
"last" : "Name",
"email" : "My.Name at mail.com",
"lucky" : 13,
"quarter" : 0.25,
"empty" : null,
"nerd" : true,
"lotto" : [ 9, 12, 17, 38, 45, 46 ],
"children" : [ "boy", "girl" ]
}
EOF
# if remove array children, then no problem.

Bob's parser parse correctly:
http://www.cis.rit.edu/~krz/hacks/jsoncvt/

print "$person"
print -r "$person"
print ${person.email}
print ${person.lotto[*]}
print -j person

unset person

compound person
person=(firstname="John" lastname="Some" age=32)
print -j person
printf "%(json)B\n" person

# both: print -j and printf after last value print out comma. Not so good
JSON format.

Loading...