Skip to content

Commit

Permalink
Merge pull request #35 from b41sh/bump-jsonb-0.3.0
Browse files Browse the repository at this point in the history
Bump to version 0.3.0
  • Loading branch information
sundy-li authored Oct 13, 2023
2 parents 2b8ddc5 + 97350fa commit 6b3f03e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## [v0.3.0] - 2023-10-13

### Added

Docs: Add more jsonb encoding format descriptions. (#34)
Feat: Support `object_each` api. (#33)
Feat: Support `path_exists` api. (#32)
Feat: Support `type_of` api. (#31)
Feat: Support `strip_nulls` api. (#30)
Perf: Add benches for parser and `get_path`. (#29)
Chore: Add check fmt and clippy. (#27)
Feat: Support `to_pretty_string` api. (#26)
Feat: Support `traverse_check_string` function. (#25)
Feat: Improve json path selector using less memory. (#24)

## [v0.2.3] - 2023-07-10

### Fixed
Expand Down
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ keywords = ["json", "jsonb", "jsonpath"]
license = "Apache-2.0"
name = "jsonb"
repository = "https://github.com/datafuselabs/jsonb"
version = "0.2.3"
version = "0.3.0"
rust-version = "1.68"

[dependencies]
byteorder = "1.4.3"
byteorder = "1.5.0"
fast-float = "0.2.0"
nom = "7.1.3"
ordered-float = { version = "3.6.0", default-features = false }
ordered-float = { version = "4.1.1", default-features = false }
rand = { version = "0.8.5", features = ["small_rng"] }
serde_json = { version = "1.0.95", default-features = false, features = [
serde_json = { version = "1.0.107", default-features = false, features = [
"preserve_order",
] }

[dev-dependencies]
goldenfile = "1.5.2"
serde_json = "1.0.105"
serde_json = "1.0.107"
json-deserializer = "0.4.4"
simd-json = {version = "0.10.6", features = ["allow-non-simd"]}
simd-json = {version = "0.11.1", features = ["allow-non-simd"]}
mockalloc = "0.1.2"
criterion = "0.5.1"

Expand Down
14 changes: 12 additions & 2 deletions src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,12 @@ pub fn is_object(value: &[u8]) -> bool {
/// Convert `JSONB` value to String
pub fn to_string(value: &[u8]) -> String {
if !is_jsonb(value) {
return String::from_utf8_lossy(value).to_string();
// empty value as default null
if value.is_empty() {
return "null".to_string();
} else {
return String::from_utf8_lossy(value).to_string();
}
}

let mut json = String::new();
Expand All @@ -1065,7 +1070,12 @@ pub fn to_string(value: &[u8]) -> String {
/// Convert `JSONB` value to pretty String
pub fn to_pretty_string(value: &[u8]) -> String {
if !is_jsonb(value) {
return String::from_utf8_lossy(value).to_string();
// empty value as default null
if value.is_empty() {
return "null".to_string();
} else {
return String::from_utf8_lossy(value).to_string();
}
}

let mut json = String::new();
Expand Down

0 comments on commit 6b3f03e

Please sign in to comment.