gron helped, I was able to find some information that was otherwise
hidden, as immediately as immediately can realistically be.
Here's a breadth-first version of outline_box (or one might prefer
box2outline) that displays an indented outline of the box structure
along with the fetch path. I think this meets my need, but wouldn't a
depth first version be nice? Example found at
https://support.oneskyapp.com/hc/en-us/articles/208047697-JSON-sample-files
.
$ ijconsole
require'~addons/convert/json/json.ijs'
linearRepresentation=: 5!:5@boxopen
outline_box=: verb define
0 outline_box (,&< {::) y
:
'content location'=. y
if. 0 = L. content do.
echo (x # ' ') , (({{linearRepresentation<'y'}} location) , ' : ' ,
": content)
else.
for_i. i. # content do.
(>: x) outline_box"0 1 content ,&<&(i&{::) location
end.
end.
)
SAMPLE=: noun define
{
"quiz": {
"sport": {
"q1": {
"question": "Which one is correct team name in NBA?",
"options": [
"New York Bulls",
"Los Angeles Kings",
"Golden State Warriros",
"Huston Rocket"
],
"answer": "Huston Rocket"
}
},
"maths": {
"q1": {
"question": "5 + 7 = ?",
"options": [
"10",
"11",
"12",
"13"
],
"answer": "12"
},
"q2": {
"question": "12 - 8 = ?",
"options": [
"1",
"2",
"3",
"4"
],
"answer": "4"
}
}
}
}
)
outline_box dec_json SAMPLE
,<0 00 : quiz
1 00;0 00 : sport
1 00;0 01 : maths
1 00;1 00;0 00 : q1
1 00;1 00;1 00;0 00 : question
1 00;1 00;1 00;0 01 : options
1 00;1 00;1 00;0 2 : answer
1 00;1 00;1 00;1 00 : Which one is correct team name in NBA?
1 00;1 00;1 00;1 01;,00 : New York Bulls
1 00;1 00;1 00;1 01;,01 : Los Angeles Kings
1 00;1 00;1 00;1 01;,2 : Golden State Warriros
1 00;1 00;1 00;1 01;,3 : Huston Rocket
1 00;1 00;1 00;1 2 : Huston Rocket
1 00;1 01;0 00 : q1
1 00;1 01;0 01 : q2
1 00;1 01;1 00;0 00 : question
1 00;1 01;1 00;0 01 : options
1 00;1 01;1 00;0 2 : answer
1 00;1 01;1 00;1 00 : 5 + 7 = ?
1 00;1 01;1 00;1 01;,00 : 10
1 00;1 01;1 00;1 01;,01 : 11
1 00;1 01;1 00;1 01;,2 : 12
1 00;1 01;1 00;1 01;,3 : 13
1 00;1 01;1 00;1 2 : 12
1 00;1 01;1 01;0 00 : question
1 00;1 01;1 01;0 01 : options
1 00;1 01;1 01;0 2 : answer
1 00;1 01;1 01;1 00 : 12 - 8 = ?
1 00;1 01;1 01;1 01;,00 : 1
1 00;1 01;1 01;1 01;,01 : 2
1 00;1 01;1 01;1 01;,2 : 3
1 00;1 01;1 01;1 01;,3 : 4
1 00;1 01;1 01;1 2 : 4
Date: Tue, 2 May 2023 12:54:27 +1000
From: Aaron Ash<[email protected]>
To:[email protected]
Subject: Re: [Jprogramming] boxes display as indented outline
Message-ID:
<CA+K9m=+rrqazumt9pg+xfvw5im+wduqeud9uu7a8um5wmu8...@mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"
I really like gron for quick json exploration:https://github.com/tomnomnom/gron
I've been meaning to write an equivalent in j but haven't yet.
Is that flattening behaviour sort of what you mean by "outline form"?
On Tue, May 2, 2023 at 12:48 PM David Lambert<[email protected]> wrote:
I've loaded a json object 9 levels deep. If a verb to display nested
box structures in outline form exists please share it with me. Usually
I just search for keys and values ignoring the structure, but this can
go awry and I thought I'd try a new method. Thanks, Dave.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm