Skip to content

Support jsonc format #457

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/file/format/jsonc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ fn from_jsonc_value(uri: Option<&String>, value: JsonValue) -> Value {
let vk = match value {
JsonValue::Null => ValueKind::Nil,
JsonValue::String(v) => ValueKind::String(v.to_string()),
JsonValue::Number(ref value) => {
if let Ok(value) = value.parse::<i64>() {
ValueKind::I64(value)
} else if let Ok(value) = value.parse::<f64>() {
ValueKind::Float(value)
JsonValue::Number(number) => {
if let Ok(v) = number.parse::<i64>() {
ValueKind::I64(v)
} else if let Ok(v) = number.parse::<f64>() {
ValueKind::Float(v)
} else {
unreachable!();
}
},
}
JsonValue::Boolean(v) => ValueKind::Boolean(v),
JsonValue::Object(table) => {
let m = table
Expand Down
2 changes: 1 addition & 1 deletion tests/file_jsonc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this?

Copy link
Contributor Author

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

assert_eq!(
s.place
.creator
Expand Down