2020-11-22 00:37:16 +00:00
|
|
|
[package]
|
JSON format output keeps braces on same line (issue #13326) (#13352)
# Description
This is a minor breaking change to JSON output syntax/style of the `to
json` command.
This fixes #13326 by setting `braces_same_line` to true when creating a
new `HjsonFormatter`.
This then simply tells `HjsonFormatter` to keep the braces on the same
line when outputting which is what I expected nu's `to json` command to
do.
There are almost no changes to nushell itself, all changes are contained
within `nu-json` crate (minus any documentation updates).
Oh, almost forgot to mention, to get the tests compiling, I added
fancy_regex as a _dev_ dependency to nu-json. I could look into
eliminating that if desirable.
# User-Facing Changes
**Breaking Change**
nushell now outputs the desired result using the reproduction command
from the issue:
```
echo '{"version": "v0.4.4","notes": "blablabla","pub_date": "2024-05-04T16:05:00Z","platforms":{"windows-x86_64":{"signature": "blablabla","url": "https://blablabla"}}}' | from json | to json
```
outputs:
```
{
"version": "v0.4.4",
"notes": "blablabla",
"pub_date": "2024-05-04T16:05:00Z",
"platforms": {
"windows-x86_64": {
"signature": "blablabla",
"url": "https://blablabla"
}
}
}
```
whereas previously it would push the opening braces onto a new line:
```
{
"version": "v0.4.4",
"notes": "blablabla",
"pub_date": "2024-05-04T16:05:00Z",
"platforms":
{
"windows-x86_64":
{
"signature": "blablabla",
"url": "https://blablabla"
}
}
}
```
# Tests + Formatting
toolkit check pr mostly passes - there are regrettably some tests not
passing on my windows machine _before making any changes_ (I may look
into this as a separate issue)
I have re-enabled the [hjson
tests](https://github.com/nushell/nushell/blob/main/crates/nu-json/tests/main.rs).
This is done in the second commit 🙂
They have a crucial difference to what they were previously asserting:
* nu-json outputs in json syntax, not hjson syntax
I think this is desirable, but I'm not aware of the history of these
tests.
# After Submitting
I suspect there `to json` command examples will need updating to match,
haven't checked yet!
2024-07-14 08:19:09 +00:00
|
|
|
authors = [
|
|
|
|
"The Nushell Project Developers",
|
|
|
|
"Christian Zangl <laktak@cdak.net>",
|
|
|
|
]
|
2020-11-22 00:37:16 +00:00
|
|
|
description = "Fork of serde-hjson"
|
2022-08-14 12:21:20 +00:00
|
|
|
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-json"
|
2022-01-20 13:13:45 +00:00
|
|
|
edition = "2021"
|
2021-10-01 05:11:49 +00:00
|
|
|
license = "MIT"
|
|
|
|
name = "nu-json"
|
2024-10-20 21:12:41 +00:00
|
|
|
version = "0.99.2"
|
2020-11-22 00:37:16 +00:00
|
|
|
|
|
|
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
|
|
|
2023-02-12 22:22:00 +00:00
|
|
|
[lib]
|
|
|
|
bench = false
|
|
|
|
|
2021-03-04 06:35:13 +00:00
|
|
|
[features]
|
|
|
|
preserve_order = ["linked-hash-map", "linked-hash-map/serde_impl"]
|
|
|
|
default = ["preserve_order"]
|
|
|
|
|
2020-11-22 00:37:16 +00:00
|
|
|
[dependencies]
|
2023-08-23 20:23:27 +00:00
|
|
|
linked-hash-map = { version = "0.5", optional = true }
|
2024-03-23 23:46:02 +00:00
|
|
|
num-traits = { workspace = true }
|
JSON format output keeps braces on same line (issue #13326) (#13352)
# Description
This is a minor breaking change to JSON output syntax/style of the `to
json` command.
This fixes #13326 by setting `braces_same_line` to true when creating a
new `HjsonFormatter`.
This then simply tells `HjsonFormatter` to keep the braces on the same
line when outputting which is what I expected nu's `to json` command to
do.
There are almost no changes to nushell itself, all changes are contained
within `nu-json` crate (minus any documentation updates).
Oh, almost forgot to mention, to get the tests compiling, I added
fancy_regex as a _dev_ dependency to nu-json. I could look into
eliminating that if desirable.
# User-Facing Changes
**Breaking Change**
nushell now outputs the desired result using the reproduction command
from the issue:
```
echo '{"version": "v0.4.4","notes": "blablabla","pub_date": "2024-05-04T16:05:00Z","platforms":{"windows-x86_64":{"signature": "blablabla","url": "https://blablabla"}}}' | from json | to json
```
outputs:
```
{
"version": "v0.4.4",
"notes": "blablabla",
"pub_date": "2024-05-04T16:05:00Z",
"platforms": {
"windows-x86_64": {
"signature": "blablabla",
"url": "https://blablabla"
}
}
}
```
whereas previously it would push the opening braces onto a new line:
```
{
"version": "v0.4.4",
"notes": "blablabla",
"pub_date": "2024-05-04T16:05:00Z",
"platforms":
{
"windows-x86_64":
{
"signature": "blablabla",
"url": "https://blablabla"
}
}
}
```
# Tests + Formatting
toolkit check pr mostly passes - there are regrettably some tests not
passing on my windows machine _before making any changes_ (I may look
into this as a separate issue)
I have re-enabled the [hjson
tests](https://github.com/nushell/nushell/blob/main/crates/nu-json/tests/main.rs).
This is done in the second commit 🙂
They have a crucial difference to what they were previously asserting:
* nu-json outputs in json syntax, not hjson syntax
I think this is desirable, but I'm not aware of the history of these
tests.
# After Submitting
I suspect there `to json` command examples will need updating to match,
haven't checked yet!
2024-07-14 08:19:09 +00:00
|
|
|
serde = { workspace = true }
|
2024-03-23 23:46:02 +00:00
|
|
|
serde_json = { workspace = true }
|
2021-03-04 06:35:13 +00:00
|
|
|
|
|
|
|
[dev-dependencies]
|
2024-10-20 21:12:41 +00:00
|
|
|
nu-test-support = { path = "../nu-test-support", version = "0.99.2" }
|
|
|
|
nu-path = { path = "../nu-path", version = "0.99.2" }
|
JSON format output keeps braces on same line (issue #13326) (#13352)
# Description
This is a minor breaking change to JSON output syntax/style of the `to
json` command.
This fixes #13326 by setting `braces_same_line` to true when creating a
new `HjsonFormatter`.
This then simply tells `HjsonFormatter` to keep the braces on the same
line when outputting which is what I expected nu's `to json` command to
do.
There are almost no changes to nushell itself, all changes are contained
within `nu-json` crate (minus any documentation updates).
Oh, almost forgot to mention, to get the tests compiling, I added
fancy_regex as a _dev_ dependency to nu-json. I could look into
eliminating that if desirable.
# User-Facing Changes
**Breaking Change**
nushell now outputs the desired result using the reproduction command
from the issue:
```
echo '{"version": "v0.4.4","notes": "blablabla","pub_date": "2024-05-04T16:05:00Z","platforms":{"windows-x86_64":{"signature": "blablabla","url": "https://blablabla"}}}' | from json | to json
```
outputs:
```
{
"version": "v0.4.4",
"notes": "blablabla",
"pub_date": "2024-05-04T16:05:00Z",
"platforms": {
"windows-x86_64": {
"signature": "blablabla",
"url": "https://blablabla"
}
}
}
```
whereas previously it would push the opening braces onto a new line:
```
{
"version": "v0.4.4",
"notes": "blablabla",
"pub_date": "2024-05-04T16:05:00Z",
"platforms":
{
"windows-x86_64":
{
"signature": "blablabla",
"url": "https://blablabla"
}
}
}
```
# Tests + Formatting
toolkit check pr mostly passes - there are regrettably some tests not
passing on my windows machine _before making any changes_ (I may look
into this as a separate issue)
I have re-enabled the [hjson
tests](https://github.com/nushell/nushell/blob/main/crates/nu-json/tests/main.rs).
This is done in the second commit 🙂
They have a crucial difference to what they were previously asserting:
* nu-json outputs in json syntax, not hjson syntax
I think this is desirable, but I'm not aware of the history of these
tests.
# After Submitting
I suspect there `to json` command examples will need updating to match,
haven't checked yet!
2024-07-14 08:19:09 +00:00
|
|
|
serde_json = "1.0"
|
2024-10-30 02:51:21 +00:00
|
|
|
fancy-regex = "0.14.0"
|
2024-08-28 21:37:17 +00:00
|
|
|
|
|
|
|
[lints]
|
2024-10-15 19:01:08 +00:00
|
|
|
workspace = true
|