Page 1 of 1
[Suggestion]Array/List nodes to be wrapped as [0]..[n] in Code-Tree for JSON data
Posted: 26.12.2023 03:09
by jordan.xue
Thanks to CudaText, it is a definitely great product.
In latest 1.206.2.0 version, I meet such a pain point. If data type is array/list in JSON, all nodes will be displayed in flat style, not structured or wrapped, not easy to address array node by sequence number.
Suggestion:
If data type is array/list in JSON, the element nodes are wrapped with sequence number like [0],[1]...[n]. User click '[0]' icon to unfold specified element data.
Thanks.
Re: [Suggestion]Array/List nodes to be wrapped as [0]..[n] in Code-Tree for JSON data
Posted: 26.12.2023 06:49
by main Alexey
code-tree for JSON is built by lexer (lexlib/JSON.lcf file).
it don't have the power to calculate [0]...[n] indexes. so it cannot do it.
what you can do:
write the tree-helper in python language.
https://wiki.freepascal.org/CudaText_API#TreeHelpers
when done, maybe you will need to disable the code-tree in JSON.lcf lexer.
https://wiki.freepascal.org/CudaText#Le ... d_creation
open JSON lexer in SynWrite app's editor, and 'disable' all items in the ui-tab for code-tree.
i think that tree-helper will be slower than lexer's work. so I don't want to use your work in distro.
Re: [Suggestion]Array/List nodes to be wrapped as [0]..[n] in Code-Tree for JSON data
Posted: 26.12.2023 07:02
by main Alexey
I tested with simple JSON array
and here I don't see list items in the code-tree. Tree shows only "p".
Re: [Suggestion]Array/List nodes to be wrapped as [0]..[n] in Code-Tree for JSON data
Posted: 26.12.2023 08:37
by jordan.xue
@Alexey,
Appreciated for your advice.
Take below json as example.
Code: Select all
{
"list": [{
"node1": {
"a": 1
},
"node2": {
"a": 1
}
}, {
"node1": {
"a": 1
},
"node2": {
"b": 1
}
}, {
"node1": {
"a": 1
},
"node3": {
"c": 1
}
} ]
}
In Code Tree, it listed like below, it is not easy to identify node1,node2 under which element in list.
Code: Select all
"list"
"node1"
"node2"
"node1"
"node2"
"node1"
"node3"
It would be more clear and friendly if display as below (as VS Code):
Code: Select all
"list"
[0]
"node1"
"node2"
[1]
"node1"
"node2"
[2]
"node1"
"node3"
Is it possible to enhance JSON lexer to support '[]' array node type view in code-tree.
thanks.
Re: [Suggestion]Array/List nodes to be wrapped as [0]..[n] in Code-Tree for JSON data
Posted: 10.01.2024 18:45
by main Alexey
no, it is not possible to configure lexer in EControl format like this. no counters there.
the solution can be this: create custom tree-helper for JSON lexer (written in Python).
https://wiki.freepascal.org/CudaText#Kinds_of_add-ons
examples:
https://sourceforge.net/projects/cudate ... eehelpers/