Skip to content

Commit

Permalink
fix: outputted keys not in same order as input
Browse files Browse the repository at this point in the history
This switches the `BTreeMap` implementation for objects out for an `IndexMap`, which means the order you write keys in is always preserved.
  • Loading branch information
JakeStanger committed Sep 14, 2023
1 parent f39d24f commit d124160
Show file tree
Hide file tree
Showing 46 changed files with 356 additions and 329 deletions.
30 changes: 27 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions assets/outputs/json/boolean.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"bar": false,
"foo": true
"foo": true,
"bar": false
}
4 changes: 2 additions & 2 deletions assets/outputs/json/chained_complex.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"bar": {
"baz": 42
},
"qux": true,
"quux": [
"green eggs",
"ham"
],
"qux": true
]
}
}
66 changes: 33 additions & 33 deletions assets/outputs/json/compact.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
{
"one": {
"foo": "bar",
"bar": "foo"
},
"two": {
"foo": 1,
"bar": 2
},
"three": {
"foo": 1.0,
"bar": 2.0
},
"four": {
"foo": true,
"bar": false
},
"five": {
"foo": null,
"bar": null
},
"six": {
"foo": {},
"bar": {}
},
"seven": {
"foo": [],
"bar": []
},
"eight": [
"foo",
"bar"
],
"eleven": [
[],
[]
],
"five": {
"bar": null,
"foo": null
},
"four": {
"bar": false,
"foo": true
},
"nine": [
true,
false
],
"one": {
"bar": "foo",
"foo": "bar"
},
"seven": {
"bar": [],
"foo": []
},
"six": {
"bar": {},
"foo": {}
},
"ten": [
null,
null
],
"three": {
"bar": 2.0,
"foo": 1.0
},
"eleven": [
[],
[]
],
"twelve": [
{},
{}
],
"two": {
"bar": 2,
"foo": 1
}
]
}
46 changes: 23 additions & 23 deletions assets/outputs/json/complex.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
{
"name": {
"first": "John",
"last": "Smith",
"full": "John Smith"
},
"age": 32,
"placeholder": null,
"employment": {
"employed": true,
"name": "Postman",
"sinceYear": 2019
},
"empty1": {},
"empty2": [],
"parents": {
"father": {
"birthday": {
"year": 1970,
"month": 2,
"day": 3
}
}
},
"gender": "M",
"favourites": [
"blue",
"fish",
Expand All @@ -15,31 +29,17 @@
4.73753,
false,
{
"hello": "world",
"food": {
"favourite": "egg",
"hated": "beef"
},
"hello": "world"
}
}
],
"gender": "M",
"name": {
"first": "John",
"full": "John Smith",
"last": "Smith"
},
"empty1": {},
"empty2": [],
"negative": {
"float": -34.34,
"int": -34
},
"parents": {
"father": {
"birthday": {
"day": 3,
"month": 2,
"year": 1970
}
}
},
"placeholder": null
"int": -34,
"float": -34.34
}
}
14 changes: 7 additions & 7 deletions assets/outputs/json/complex_keys.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"with_underscore": 0,
"with-dash": 1,
"with_🌽": 2,
"!\"£$%^&*()_": 3,
"apple-pie": {
"crust": "yum"
},
"j12345": 4,
"foo": {
"bar-baz": "hello"
},
"j12345": 4,
"with-dash": 1,
"with_underscore": 0,
"with_🌽": 2
"apple-pie": {
"crust": "yum"
}
}
4 changes: 2 additions & 2 deletions assets/outputs/json/float.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"bar": 101.0,
"foo": 3.14159
"foo": 3.14159,
"bar": 101.0
}
8 changes: 4 additions & 4 deletions assets/outputs/json/input.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": {
"first": "John",
"last": "Smith"
},
"dob": {
"day": 1,
"month": 1,
"year": 1970
},
"name": {
"first": "John",
"last": "Smith"
}
}
4 changes: 2 additions & 2 deletions assets/outputs/json/integer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"foo": 42,
"bar": 16448250,
"baz": 1000000,
"foo": 42
"baz": 1000000
}
4 changes: 2 additions & 2 deletions assets/outputs/json/object_in_array.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"foo": [
{
"bar": 2,
"foo": 1
"foo": 1,
"bar": 2
}
]
}
36 changes: 18 additions & 18 deletions assets/outputs/json/readme_example.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
{
"author": {
"email": "mail@example.com",
"name": "John Smith",
"url": "https://example.com"
},
"name": "example-package",
"version": "1.0.0",
"main": "dist/index.js",
"bin": {
"filebrowser": "dist/index.js"
},
"config": {
"hostname": null,
"port": 8080
"private": false,
"author": {
"name": "John Smith",
"email": "mail@example.com",
"url": "https://example.com"
},
"contributors": [
{
"email": "mail@example.com",
"name": "John Smith"
"name": "John Smith",
"email": "mail@example.com"
}
],
"scripts": {
"build": "tsc",
"run": "node dist"
},
"dependencies": {
"dotenv": "^8.2.0"
},
"devDependencies": {
"typescript": "^4.5"
},
"main": "dist/index.js",
"name": "example-package",
"private": false,
"scripts": {
"build": "tsc",
"run": "node dist"
},
"version": "1.0.0"
"config": {
"port": 8080,
"hostname": null
}
}
2 changes: 1 addition & 1 deletion assets/outputs/json/spread.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"bar": "baz",
"hello": "world",
"bar": "baz",
"nums": [
1,
2,
Expand Down
2 changes: 1 addition & 1 deletion assets/outputs/json/string.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"foo": "bar",
"bar": "\"\\\n\r\t",
"baz": "a",
"foo": "bar",
"qux": ""
}
4 changes: 2 additions & 2 deletions assets/outputs/json/string_interpolation.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"bar": "$escaped",
"foo": "hello, world"
"foo": "hello, world",
"bar": "$escaped"
}
Loading

0 comments on commit d124160

Please sign in to comment.