Releases: khonsulabs/justjson
v0.3.0
Updated
- Heapless has been updated to v0.8
Added
-
JsonNumber
andValue
now have these additional helpers for converting to
native numeric types:as_u8
as_u16
as_u32
as_u64
as_u128
as_usize
as_i8
as_i16
as_i32
as_i64
as_i128
as_isize
as_f32
as_f64
-
JsonNumber::parse()
is a new function that uses a typesFromStr
implementation to parse the source of the numeric literal.
v0.2.3
Changed
- This crate's MSRV has been changed to 1.65. This is not a breaking change,
however, as the crate never supported its advertised MSRV, and this new MSRV
reflects what the true MSRV has always been. An additional CI pass was added
to ensure the MSRV is always tested against. Thanks to @hr8 in #8 for
reporting this.
Added
-
AnyStr::as_str()
has been added, which acts the same as
AsRef<str>
/Borrow<str>
/Deref<Target = str>
. -
JsonString::as_str()
has been added, which will return an&str
to the
contained string, if it doesn't contain escape sequences. If the string has
escape sequences, None will be returned. -
Value::as_str()
has been added, which will return an&str
to the contained
string if the theValue
is aJsonString
that has no escape sequences. If
the value is not a string or it has escape sequences, None will be returned. -
JsonString
now implementsDisplay
with the decoded representation. This
also means thatToString
is now implemented such that it produces a decoded
string. -
Tokenizer
is a new low-level parsing type that provides basic tokenization.
Thank you to @indietyp in #13 for refactoring the parser to expose this
functionality!
v0.2.2
Added
-
JsonString
now implementsOrd
,PartialOrd
, andPartialOrd<str>
, and
Hash
. -
Entry
, the type whichObject
is a collection of, is now exported. This was
an oversight. Thanks to @PoiScript for reporting this in #6. -
Value::get(key)
,Value::get_mut(key)
, andIndex<&str>
/IndexMut<&str>
have been added to allow easier access to the contents of aValue
when it is
an object. Similar to most built-in collection types, theIndex
trait
implementations will panic if the key is not found, but theget
variants
return an Option instead of panicking. -
Value::get_index(usize)
,Value::get_index_mut(usize)
, and
Index<usize>
/IndexMut<usize>
have been added to allow easier access to the
contents of aValue
when it is an array. Similar to most built-in collection
types, theIndex
trait implementations will panic if the index is out of
bounds, but theget_index
variants return an Option instead of panicking. -
From<&str>
,From<String>
,From<JsonString<'_>>
,From<Object<'_>>
, and
From<bool>
have been implemented forValue<'_>
.
v0.2.1
This release contains no code changes. The Cargo.toml
section for docs.rs has
been updated in an attempt to enable doc_auto_cfg
, which annotates what
features flags are needed for any given item in the documentation.
For the changes from v0.1.0, see the v0.2.0 release.
v0.2.0
Breaking Changes
-
Value
,Object
,JsonNumber
, andJsonString
have all changed from having
a generic parameter to having a single lifetime parameter. Internally, all
strings have been changed toCow<'_, str>
to allow for owned values to be
injected into aValue
/Object
orVec<Value<'_>>
. -
JsonString::source
has been removed from the public API.
JsonString::contents()
is now available to provide read-only access to the
JSON-encoded representation. -
JsonNumber::source
has been removed from the public API.
JsonNumber::source()
is now available to provide read-only access to the
JSON-encoded representation. -
JsonString
now internally can be a JSON-encoded string or a raw string, and
it will encode or decode escape sequences on the fly as needed. This means
adding a new raw &str that needs escaping will not actually incur extra
allocations while rendering a Value back to JSON, as the encoding operation
will occur during the write to the destination. -
Object::push()
has been removed, and itsDeref
implementation now targets
Vec<Entry<'a>>
. This allows allVec
methods to be used to access the
contents of an Object, including its ownpush()
function. -
ParseDelegate::Error
is a new associated type that is now able to be
returned from mostParseDelegate
functions as the Error type of the Result.
Previously, most functions did not return a Result.Returning an error from a
ParseDelegate
function will stop parsing the
underlying document immediately and return the error in
ErrorKind::ErrorFromDelegate
.
Fixes
- Escaped UTF16 surrogate pairs are properly handled. Previously, all surrogates
were considered invalid unicode. - Leading
+
signs are no longer allowed on numbers. - Leading
0
s are now disallowed on negative numbers.
Added
-
JsonString::from(&str)
has been added to convert from a Rust string to its
JSON-encoded form. -
#1: This crate now is
no_std
compatible. Theno_std
support is controlled by
three feature flags:std
: Enabled by default, enablesalloc
automatically.alloc
: Uses thealloc
crate for theDocument
andValue
types.heapless
: Exports a newHeaplessDocument
type that can be used in
environments withoutalloc
.
Without any features enabled, only
Parser
,GenericDocument
,JsonString
,
andJsonNumber
are available to parse JSON.To enable
GenericDocument
to work with types other thanVec
and
heapless::Vec
,NodeCollection
can be implemented for other Vec-like types.
Changed
thiserror
has been removed from the dependencies in favor of manually
implementingstd::error::Error
. This makesjustjson
dependency free
without enabling extra feature flags.