-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support jsonc format #457
base: main
Are you sure you want to change the base?
Support jsonc format #457
Conversation
Signed-off-by: T.C. <8325632+up9cloud@users.noreply.github.com>
Signed-off-by: T.C. <8325632+up9cloud@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some remarks. Also, the two commits could be squashed into one commit,... as well as further fixups of course!
Either way thanks for your contribution!
@@ -52,7 +52,7 @@ fn test_file() { | |||
assert_eq!(s.place.telephone, None); | |||
assert_eq!(s.elements.len(), 10); | |||
assert_eq!(s.elements[3], "4".to_string()); | |||
if cfg!(feature = "preserve_order") { | |||
if cfg!(feature = "TODO: preserve_order") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, that's because jsonc-parser doesn't support preserve_order. need time to contribute that
#[cfg(all(feature = "jsonc", feature = "json"))] | ||
formats.insert(FileFormat::Jsonc, vec!["jsonc"]); | ||
|
||
#[cfg(all(feature = "jsonc", not(feature = "json")))] | ||
formats.insert(FileFormat::Jsonc, vec!["jsonc", "json"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that the jsonc
parser also parses json
even if that feature is disabled?
I think that's counter-intuitive and we should only parse jsonc
with the jsonc
parser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, there are 2 reasons i added that.
- the file extension for jsonc is actually
.json
, not.jsonc
, so the real question is that when i enable the featurejsonc
it's about the format or the file extension? - for the common usage, people would choose only one of them, not both. and I believe the jsonc format is more common for config files than the json format.
I did a new commit, see #452