Comments (5)
Well, I guessed that might be the cause, but the underlying implementation shouldn't matter, right? The option is confusing when it works this way. What's the use of a non-sorted output if the input is being modified in the first place 😅?
from gron.
+1 to --no-sort
preserving input order if that's not to difficult to implement. Right now there is no way to retain order, but order often is often explicitly set in JSON objects to aid in interpretation / human-legibility.
from gron.
BTW this tool is fantastic and helps me a lot! Thanks for creating it :)
from gron.
--no-sort
tells gron not to sort the output. It doesn't guarantee a stable order - if you want that, let it sort. The instability comes from the underlying Go map
object, which randomizes string hashing functions.
from gron.
Hi,
I just tried with the tool I wrote ( https://github.com/adamritter/fastgron ), it preserves the order with gron (I'm not sure about ungron though yet :( )
for i in $( seq 1000 ); do echo '{"z": "first", "a": "last"}' | gron --no-sort | column -x; done | sort | uniq -c;
130 json = {}; json.a = "last"; json.z = "first";
870 json = {}; json.z = "first"; json.a = "last";
(base) ➜ ~/Documents/GitHub/fastgron/fastgron git:(main) for i in $( seq 1000 ); do echo '{"z": "first", "a": "last"}' | fastgron --no-sort | column -x; done | sort | uniq -c;
1000 json = {} json.z = "first" json.a = "last"
from gron.
Related Issues (20)
- Ungron doesn't respect --no-sort option HOT 1
- Output format HOT 12
- more tollerance when parsing
- Remove this HOT 1
- Export functions? HOT 1
- asdf gron
- Colour - Support Highlighting when Ungronning from grep.
- Bash completions HOT 1
- gron will fail to link at runtime once OpenBSD removes syscall(2)
- Auto-provide command line completions
- panic with --values HOT 1
- Add github topics? HOT 1
- `gron URL` doesn't use the proxy defined in environment HOT 2
- Latest release
- ungron is slow and leaky HOT 7
- Binary builds broken?? HOT 4
- Add release for armv6l
- Special-case `new Array()` and `new Object`
- v0.7.1 does not report its own version HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gron.