Thanks Marc, that bug is now fixed by x=. ,&.> boxopen x
Втр, 05 Июн 2012, Marc Simpson писал(а): > While tinkering with 'convert/json' this evening I encountered a problem in > retrieving single-character keys from a decoded JSON object. > > Here's a simple example: > > b1 =: dec_json'{ "a": 1, "b": 2}' > b2 =: dec_json'{"cd": 3,"ef": 4}' > > 'a' gethash_json b1 > _1 > 'b' gethash_json b1 > _1 > 'cd' gethash_json b2 > +-+ > |3| > +-+ > 'ef' gethash_json b2 > +-+ > |4| > +-+ > > i.e., retrieval from 'b2' works as expected while single character key > lookup in 'b1' fails. The problem seems to be that single character keys > aren't being raveled prior to boxing: > > ({.boxopen'a') e. {.b1 > 0 > ({.boxopen,'a') e. {.b1 > 1 > > Am I overlooking something obvious (or misusing gethash_json)? If not, > here's a simple fix, > > gethash_json=: 4 : 0 > assert. 2=$$y > assert. 32=3!:0 y > x=. boxopen ,x NB. fix > assert. 1=$x > if. ({.x) e. {.y do. > ({:y){~({.y) i. {.x > else. > _1 > end. > ) > > Best, > M > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm -- regards, ==================================================== GPG key 1024D/4434BAB3 2008-08-24 gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm