simeji / jid Goto Github PK
View Code? Open in Web Editor NEWjson incremental digger
License: MIT License
json incremental digger
License: MIT License
I'm exploring a json document consisting of an array of arrays grouped by a key. [[{"k":1,},{"k":1}],[{"k":2}]]
. As I query > .[0]
and try appending [*]
. If I go back and try to add .
just after the initial .[0]
it overwrites the line before it. It seems that in order to edit an earlier part of the line, I need to always rewrite the line that follows.
The issue may be exacerbated by the behavior that filters are not evaluated until a whole new component is recognized, so it's hard to discover syntax because of a slower feedback loop.
We press TAB
to navigate next matching field. It would be nice to use shift+tab
to go to previous.
Could you support the feature to show the array length? Similar to jq .users | length
.
al123xiaaaa@HASEE-PC:/jid$ ls -l/jid$ echo '{"info":{"date":"2016-10-23","version":1.0},"users":[{"name":"simeji","uri":"https://github.com/simeji","id":1},{"name":"simeji2","uri":"https://example.com/simeji","id":2},{"name":"simeji3","uri":"https://example.com/simeji3","id":3}],"userCount":3}}'| ./jid_linux_amd64
total 3584
-rwxrwxrwx 1 al123xiaaaa al123xiaaaa 3044060 Dec 6 23:17 jid_linux_amd64
al123xiaaaa@HASEE-PC:
panic: invalid argument
goroutine 1 [running]:
panic(0x514ee0, 0xc42000a7d0)
/usr/local/Cellar/go/1.7.1/libexec/src/runtime/panic.go:500 +0x1a1
github.com/simeji/jid.(*Engine).Run(0xc4200b6000, 0x0, 0x0)
/Users/ts/go/src/github.com/simeji/jid/engine.go:87 +0x7f3
main.run(0x5babe0, 0xc4200b6000, 0x534000, 0x1)
/Users/ts/go/src/github.com/simeji/jid/cmd/jid/jid.go:36 +0x49
main.main()
/Users/ts/go/src/github.com/simeji/jid/cmd/jid/jid.go:31 +0x10f
To reach success in the following file, the jq expression is .["\""]
. But jid produces ."
Input file:
{
"\"": "key with double quote: success!",
}
Can we change the way the program exits when you hit the 'Enter' button? Maybe make the default exit ctrl-C?
Pressing 'Enter' should select the given auto-complete suggestion.
When reading big jsons, sometimes is nice to be able to just do a plain search, as you would do with less
: Press /
time string to search and enter in search mode.
For instance, to search for all cases with http://
/
or ?
to enter search mode.n
/N
to navigate next/prev occurrencesEnter
select current search occurrence and populate filter with the corresponding pathEsc
exit search pathConsiderations:
Autocomplete and selection break down when the keys contain periods. Example use case:
{
"hosts": {
"192.168.0.1": "a",
"192.168.1.1": "b"
}
}
Thanks for releasing this - I'm a big fan :)
Is there interest in covering off more of the jq
builtins?
For instance:
echo '{"abc": 1, "abcd": 2, "Foo": 3}' | jq 'keys'
["Foo", "abc", "abcd"]
jid prevents me typing keys
at all at the moment.
Could we get support for JSON that isn't so strictly formatted:
{
foo: "bar",
// Comment for good measure
baz: "foo",
}
In the wild JSON is going to appear like this a lot.
If jid support CTRL + U to clear the query, it will be more awesome.
Seems to either hang or not allow input
Hi, just a matter to make it easier to use, if you can remove the "<" to open a file.
Also, if you jid file
or jid
then nothing happens but it hangs.
Go Releaser lets you do release management (generation of binaries, rpms, debs, brew taps, change logs etc) with a single yaml file.
You can also put in godownloader to generate an install script that can be used for downloading release binaries from github releases. It is made by the same goreleaser team
For inspiration you can take a look at the awesome golangci-lint project
Bottom line: Installation and release management becomes way cooler 😎
Hello,
I tried jid
and this tool looks really great, thx for that.
I have question about formatting. When I tried the example from readme I see all the time json in one-line format:
$ echo '{"aa":"2AA2","bb":{"aaa":[123,"cccc",[1,2]],"c":321}}' | jid
[Filter]> .
{"aa":"2AA2","bb":{"aaa":[123,"cccc",[1,2]],"c":321}}
I tried to use python -m json.tool
but still the same result:
echo '{"aa":"2AA2","bb":{"aaa":[123,"cccc",[1,2]],"c":321}}'| python -m json.tool | jid
Completion or just input don't work for empty string key. With jq I would use this expression: .[""]
Here is an example JSON:
{
"": "empty key: success!",
}
instead of silently ignoring everything except the dot character, just start with it inserted, or don't require it at all
jid version v0.6.2
Test json file:
{ "a": 123, "aa": 124, "bb": 567 }
Identify a bug:
jid < test.json
a
I expected 123, but saw full json file.
Be able to enter in a cursor mode, that would allow to navigate the json in RAW using cursors or vim hjkl
.
Ctrl+n
) for cursor navigationesc
to go back to filter modeEnter
to focus the current json node where the cursor is, and automatically fill the filter mode (See #77)Optionally: allow select some text pressing shift.
often, you want to be piping this to jq
, and not as the final output
Colorful output is really missing.
This feature could be optional like in jq (-C
colorize output, -M
monochrome output). It's not vital, but would be a really nice to have.
To correct the version, I'm needing to do
# Fix version
inreplace "cmd/jid/jid.go", "VERSION = \"0.6.2\"",
"VERSION = \"#{version}\""
Is this something I should be passing via LDFLAGS or should it bumped in the code each time it's tagged? Thanks!
I have a 2016 MacBook Pro (pretty fast machine), but if I give jid as input a 7MB JSON file that is on my local SSD drive, performance is very slow; each character I type takes about 3 seconds to respond.
The JSON file consists of about 27,000 items. The file is structured like this:
{
(item),
(item),
(item)
}
Each (item) looks like this:
"128708": {
"id_1": 132499,
"id_2": "1939",
"lang": {
"qc": 1
},
"items": [
130556,
126889,
129103,
131423,
126300,
131270,
134335,
134483,
141317,
136120
],
"date": "7/7",
"category": 133089,
"cr_dt": "7/8/2001",
"d_year": "2004",
"some_id2": 132589,
"b_year": "1/22",
"l_en": {
"qc": 3,
"path": "jeffsmith",
"name": "Jeff Smith"
}
}
I do:
jid < /tmp/some.json
With that as an input if I type "1" it takes about 3 seconds before jid reponds, then if I type "2" it takes another 3 seconds, and so on.
Is there a way this could be improved to be faster?
Arrow up/down are not being used, why not map them to Ctrll+j/k. Same for page up/down
$ echo '' | jid
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x469292]
goroutine 1 [running]:
panic(0x513220, 0xc42000a0e0)
/usr/local/Cellar/go/1.7.1/libexec/src/runtime/panic.go:500 +0x1a1
github.com/simeji/jid.(*JsonManager).GetFilteredData(0x0, 0x0, 0x0, 0xc420039b00, 0xc420039be0, 0x43bb3b, 0xc420039be0, 0x42fdce, 0xc420039bb8, 0x4a51d1, ...)
/Users/ts/go/src/github.com/simeji/jid/json_manager.go:63 +0x42
github.com/simeji/jid.(*JsonManager).GetPretty(0x0, 0x0, 0x0, 0x0, 0xbf00000004,
0x7f1c030000000a30, 0x1a13110001000415, 0xc420039cc8, 0x425d33, 0xc420039c98, ...)
/Users/ts/go/src/github.com/simeji/jid/json_manager.go:54 +0x66
github.com/simeji/jid.(*Engine).getContents(0xc420090000, 0x544748, 0x543513, 0x543512)
/Users/ts/go/src/github.com/simeji/jid/engine.go:160 +0x5d
github.com/simeji/jid.(*Engine).Run(0xc420090000, 0x0, 0x0)
/Users/ts/go/src/github.com/simeji/jid/engine.go:92 +0xb4
main.run(0x5babe0, 0xc420090000, 0x5bab00, 0xc420090000)
/Users/ts/go/src/github.com/simeji/jid/cmd/jid.go:24 +0x49
main.main()
/Users/ts/go/src/github.com/simeji/jid/cmd/jid.go:19 +0xc5
The drilldown token .
can appear in the key name of the json object and will break drilling down
> echo '{ "a.a": 123 }' | jid
[Filter]> .
{
"a.a": 123
}
[Filter]> .a.a
null
[Filter]> ."a.a"
null
The first prompt suggested the autocomplete .a.a
which doesn't work.
I've tried to use jid
on a 16MB (minified) JSON file on an M1 Pro (32GB) and it's as slow or slower as described in #66
Interestingly, the slowness ends when what's filtered to is no longer in the MB range.
The .[]
filter works fine in jq:
❯ echo '[{"id":1},{"id":2}]' | jq '.[]'
{
"id": 1
}
{
"id": 2
}
But returns null
in jid.
Is there any reason for this? I couldn't spot any explanation in the documentation.
Thanks!
So users don't have to tap
.
How can I use wildcards in queries?
For example consider this.
echo '{"users":[{"name":"s1","id":1},{"name":"s2","id":2}]}'|jid
I can query users[0].id
or users[1].id
.
How can I get all the ids? I tried users[*].id
which didn’t work.
In Clojure I use specter for this which is able to handle wildcards using ALL
.
Here is a use case for this. Suppose I get the JSON from AWS using awscli
containing all the EC2 instances. I want to extract the public IP addresses of all the instances.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.