Giter Club home page Giter Club logo

serde-json-core's Introduction

serde-json-core

serde-json for no_std programs

This project is developed and maintained by the rust-embedded-community.

Minimum Supported Rust Version (MSRV)

This crate is guaranteed to compile on stable Rust 1.62.0 and up. It might compile with older versions but that may change in any new patch release.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

serde-json-core's People

Contributors

avlec avatar bors[bot] avatar dflemstr avatar eldruin avatar elrafoon avatar fionawhim avatar gbip avatar japaric avatar jordens avatar mabezdev avatar mathiaskoch avatar r-marques avatar rfael avatar ryan-summers avatar sigmaris avatar vhdirk avatar xabra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

serde-json-core's Issues

`cargo check` failure

the trait bound de::Error: std::error::Error is not satisfied.

->

   Checking serde-json-core v0.0.1
error[E0277]: the trait bound `de::Error: std::error::Error` is not satisfied
  --> /home/sanmai/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/de/enum_.rs:17:15
   |
17 | impl<'a, 'de> de::EnumAccess<'de> for UnitVariantAccess<'a, 'de> {
   |               ^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `de::Error`

error[E0277]: the trait bound `de::Error: std::error::Error` is not satisfied
  --> /home/sanmai/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/de/enum_.rs:30:15
   |
30 | impl<'de, 'a> de::VariantAccess<'de> for UnitVariantAccess<'a, 'de> {
   |               ^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `de::Error`

error[E0277]: the trait bound `de::Error: std::error::Error` is not satisfied
  --> /home/sanmai/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/de/map.rs:19:15
   |
19 | impl<'a, 'de> de::MapAccess<'de> for MapAccess<'a, 'de> {
   |               ^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `de::Error`

error[E0277]: the trait bound `de::Error: std::error::Error` is not satisfied
  --> /home/sanmai/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/de/map.rs:69:15
   |
69 | impl<'de, 'a> de::Deserializer<'de> for MapKey<'a, 'de> {
   |               ^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `de::Error`

error[E0277]: the trait bound `de::Error: std::error::Error` is not satisfied
  --> /home/sanmai/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/de/seq.rs:19:15
   |
19 | impl<'a, 'de> de::SeqAccess<'de> for SeqAccess<'a, 'de> {
   |               ^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `de::Error`

error[E0277]: the trait bound `de::Error: std::error::Error` is not satisfied
   --> /home/sanmai/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/de/mod.rs:265:15
    |
265 | impl<'a, 'de> de::Deserializer<'de> for &'a mut Deserializer<'de> {
    |               ^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `de::Error`

error[E0277]: the trait bound `de::Error: std::error::Error` is not satisfied
   --> /home/sanmai/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/de/mod.rs:541:6
    |
541 | impl de::Error for Error {
    |      ^^^^^^^^^ the trait `std::error::Error` is not implemented for `de::Error`

error[E0277]: the trait bound `ser::Error: std::error::Error` is not satisfied
  --> /home/sanmai/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/ser/seq.rs:24:13
   |
24 | impl<'a, B> ser::SerializeSeq for SerializeSeq<'a, B>
   |             ^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `ser::Error`

error[E0277]: the trait bound `ser::Error: std::error::Error` is not satisfied
  --> /home/sanmai/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/ser/seq.rs:50:13
   |
50 | impl<'a, B> ser::SerializeTuple for SerializeSeq<'a, B>
   |             ^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `ser::Error`

error[E0277]: the trait bound `ser::Error: std::error::Error` is not satisfied
  --> /home/sanmai/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/ser/struct_.rs:24:13
   |
24 | impl<'a, B> ser::SerializeStruct for SerializeStruct<'a, B>
   |             ^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `ser::Error`

error[E0277]: the trait bound `ser::Error: std::error::Error` is not satisfied
   --> /home/sanmai/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/ser/mod.rs:121:13
    |
121 | impl<'a, B> ser::Serializer for &'a mut Serializer<B>
    |             ^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `ser::Error`

error[E0277]: the trait bound `ser::Error: std::error::Error` is not satisfied
   --> /home/sanmai/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/ser/mod.rs:339:6
    |
339 | impl ser::Error for Error {
    |      ^^^^^^^^^^ the trait `std::error::Error` is not implemented for `ser::Error`

error[E0277]: the trait bound `ser::Error: std::error::Error` is not satisfied
   --> /home/sanmai/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/ser/mod.rs:350:6
    |
350 | impl ser::SerializeTupleStruct for Unreachable {
    |      ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `ser::Error`

error[E0277]: the trait bound `ser::Error: std::error::Error` is not satisfied
   --> /home/sanmai/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/ser/mod.rs:363:6
    |
363 | impl ser::SerializeTupleVariant for Unreachable {
    |      ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `ser::Error`

error[E0277]: the trait bound `ser::Error: std::error::Error` is not satisfied
   --> /home/sanmai/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/ser/mod.rs:376:6
    |
376 | impl ser::SerializeMap for Unreachable {
    |      ^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `ser::Error`

error[E0277]: the trait bound `ser::Error: std::error::Error` is not satisfied
   --> /home/sanmai/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/ser/mod.rs:399:6
    |
399 | impl ser::SerializeStructVariant for Unreachable {
    |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `ser::Error`

error: aborting due to 16 previous errors

Meta

cargo 1.31.0-nightly (5dbac9888 2018-10-08)
release: 1.31.0
commit-hash: 5dbac98885199bbd7c0f189d7405b5523434d1e3
commit-date: 2018-10-08

rustc 1.31.0-nightly (46880f41b 2018-10-15)
binary: rustc
commit-hash: 46880f41b7aeb897b8245474196bba9dc11f0e88
commit-date: 2018-10-15
host: x86_64-unknown-linux-gnu
release: 1.31.0-nightly
LLVM version: 8.0

Detect string end quotes correctly

Right now in parse_str, each " character is considered a JSON string terminator. This is incorrect because it ends strings even at escaped quotes. E.g.

{
  "title": "hello \"world\""
}

is parsed as title = "hello\" and the rest is considered broken data.

String end detection can be implemented without unescaping strings (and thus remains zero-copy). If someone is interested to do so, feel free to re-use the implementation from CosmWasm#11.

Feature Request: Support defmt Formatting

Working on a an embedded project where there is the ability to log errors and structures with defmt, this does require adding a new conditional dependency and adding a conditional derive as follows. This would be particularly useful for reporting errors from JSON de-serialization.

#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Error {
...
}

Cannot be combined with serde std

I'm writing a library which uses serde and which may be used with or without std present. I also need to do some JSON manipulation. The serde-json library depends on alloc, which I can't do, so I have to use this library. However, this library seems to not compile if I compile it with serde having the feature std enabled. Specifically, this is the compile error I get:

error[E0277]: the trait bound `de::Error: StdError` is not satisfied
   --> serde-json-core-0.4.0/src/de/mod.rs:661:6
    |
661 | impl de::Error for Error {
    |      ^^^^^^^^^ the trait `StdError` is not implemented for `de::Error`
    |
note: required by a bound in `serde::de::Error`
   --> serde-1.0.137/src/de/mod.rs:299:1
    |
299 | declare_error_trait!(Error: Sized + StdError);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `serde::de::Error`
    = note: this error originates in the macro `declare_error_trait` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `ser::Error: StdError` is not satisfied
   --> serde-json-core-0.4.0/src/ser/mod.rs:458:6
    |
458 | impl ser::Error for Error {
    |      ^^^^^^^^^^ the trait `StdError` is not implemented for `ser::Error`
    |
note: required by a bound in `serde::ser::Error`
   --> serde-1.0.137/src/ser/mod.rs:183:1
    |
183 | declare_error_trait!(Error: Sized + StdError);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `serde::ser::Error`
    = note: this error originates in the macro `declare_error_trait` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0277`.
error: could not compile `serde-json-core` due to 2 previous errors

I encounter this issue if I make a new package and put this crate and serde as dependencies. For reference, it compiles fine if I don't include the std feature on serde. Also, I'm using rust version 1.61.

Can this crate be changed to not break if it gets used with serde with std enabled?

Library panics when deserializing certain types due to `unreachable!()` statements

When deserializing certain types, the library may hit unreachable!() statements, which results in a panic. This appears to be because serde-json-core does not support deserializing complex enums (e.g. pub struct Test(u32).

That being said, the library should never internally panic. Instead, it should propagate an error out to the user.

Serialize into externally allocated buffer

It would be nice to have the option of passing in a byte slice to be used in serialization, rather than the internal buffer.

Usecase example:

pub fn as_json(&self, buf: &mut [u8]) -> Result<usize, ()> {
    let json = serde_json_core::to_vec::<consts::U1024, _>(&self).map_err(|_e| ())?;
    let len = json.len();
    buf[..len].copy_from_slice(&json);
    Ok(len)
}

Would be awesome to be able to:

pub fn as_json(&self, buf: &mut [u8]) -> Result<usize, ()> {
    let len = serde_json_core::to_slice(&self, &buf).map_err(|_e| ())?;
    Ok(len)
}

Where to_slice would just populate buf[0..len] with the serialized output.

String escaping

As documented in https://github.com/japaric/serde-json-core/blob/238c8fe/src/lib.rs#L46, strings are not escaped in serialization. This leads to broken JSON results when e.g. a " character exists as part of the string content.

If someone wants to tackle this, feel free to copy the implementation from CosmWasm#10.

You probably need to work on unescaping at the same time (which is hard and not zero-copy) if you want deserialize(serialize(original)) == original. For a seralize-only use case however, escaping is an important independent step.

Example Proposition for str deserialization

Hello Guys,
This is a great crates !

But as a rust newcomer I was a bit lost face to:

Supports deserialization of:
    [...]
    str (This is a zero copy operation.) (*)
    [...]

Examples of std serde use dynamic allocation and don't speak about this use case.

I put here a proposition of example that would have helped me. If you put this in your documentation I'm sure it will help other newcomers.

// Import
use serde::{Deserialize};
use serde_json_core;

// The field is a ref that will point directly in the parsed buffer
#[derive(Deserialize)]
struct MyStruct<'a> {
    the_str: &'a str,
}

// Deserialize buffer
match serde_json_core::de::from_slice::<MyStruct>( b"{\"the_str\": \"jsoncore\"}" ) {
    Err(_e) => {
        // Err
    }
    Ok(deser) => {
        // result in deser.0.the_str
    }
}

Trying to deserialize the wrong json result in a panic

When trying to deserialize a valid json that does not represent the expected struct, the deserializer calls deserialize_ignored_any which should be unreachable.

Here is an example inspired by some code that we used in production :

use serde_json_core::de::{from_slice, Error as DError};

#[derive(Debug, Copy, Clone, Deserialize, Serialize)]
pub enum IOState {
    On,
    Off,
}

#[derive(Debug, Copy, Clone, Deserialize, Serialize)]
pub struct Pneumatic {
    pub pumps: [IOState; 2],
    pub pump_intensity: [u16; 2],
    pub valves: [IOState; 6],
}

impl Pneumatic {
    fn from_json_slice(slice: &[u8]) -> Result<Self, DError> {
        from_slice(slice)
    }
}
#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn deser_fail() {
        let b = Pneumatic::from_json_slice(
            "{\"pump_intensity\":[0,0],\"pumps\":[\"On\",\"On\"],\"valves\":[\"Off\",\"On\",\"On\",\"Off\",\"On\",\"Off\"]}".as_bytes()).unwrap();
       // This line fails
        let c = Pneumatic::from_json_slice(
            "{\"tirette\":\"Triggered\",\"buzzer\":\"PlayErrorSound\"}".as_bytes(),
        );
    }

}

You can find the code to replicate this issue on this branch (ready to be cloned).

Please tell me if I can do anything else to document this issue ! ๐Ÿ˜„

deserialize_str with escaped strings is broken

serde_json_core needs to refuse deserializing a borrowed string with escape sequences.

serde_json_core::from_slice::<&str>(br#""\n""#) incorrectly gives Ok(("\\n", 4)).

serde_json::from_slice::<&str>(br#""\n""#) correctly says Error("invalid type: string \"\\n\", expected a borrowed string", line: 1, column: 4).

Proposal: feature flag for float support

Floating point operations are known to be problematic when it comes to determinism. In the blockchain space, we tend to avoid them (and rather use decimal types). At https://github.com/CosmWasm/serde-json-wasm we maintain a fork of this repo that is specialized on WebAssembly and blockchain. I think it would be cool to be able to keep the repos in sync as much as possible.

Since we check all the WebAssembly instructions in the blockchain, they need to be non-existent in the compilation result (no matter if used or not). Would you accept a PR adding a floats feature flag (turned on by default)? This is for sure not a general purpose request. But maybe it is interesting for other users as well that either worry about code size or determinism.

Add support for alloc::* types

Currently I have following errors:

error[E0277]: the trait bound `alloc::String: serde::Serialize` is not satisfied
  --> C:\Users\Alex\Documents\Repo\pwasm-abi\derive\src\json.rs:14:10
   |
14 | #[derive(Serialize, Debug)]
   |          ^^^^^^^^^ the trait `serde::Serialize` is not implemented for `alloc::String`
   |
   = note: required by `serde::ser::SerializeStruct::serialize_field`

Could it be done in no-std scenario?

Library should publicly export heapless

Currently, if the user application and serde-json-core are using different versions of heapless, the compiler may throw strange errors:

(Example here, app uses heapless 0.6.0, serde-json-core 0.2.0)

error[E0308]: mismatched types
  --> src\net\router.rs:54:24
   |
54 |         self.message = serde_json_core::to_vec(&response).unwrap();
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `heapless::Vec`, found struct `heapless::vec::Vec`
   |
   = note: expected struct `heapless::Vec<u8, UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>`
              found struct `heapless::vec::Vec<u8, _>`
   = note: perhaps two different versions of crate `heapless` are being used?

We should likely be publicly using the heapless types here to allow external users to sync up exactly with the version of heapless the library is using.

Bump dependencies

Crate is currently working with heapless v0.2.4 and serde_derive v1.0.33. I think versions should be bumped, because these versions contains different bugs and so on. Unfortunately, changes in heapless was too big so I'm just not able to figure out how they should be fixed.

Cannot compile with nightly 1.38

I was trying to convert from serde-json to serde-json-core to get smaller sizes on my wasm code. I was also happy not to pull in any floating support, as I only want ints. However, I got the following error (about 50 times) when compiling:

error[E0277]: the trait bound `ser::Error: serde::de::StdError` is not satisfied
   --> /home/ethan/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/ser/mod.rs:121:13
    |
121 | impl<'a, B> ser::Serializer for &'a mut Serializer<B>
    |             ^^^^^^^^^^^^^^^ the trait `serde::de::StdError` is not implemented for `ser::Error`

error[E0277]: the trait bound `ser::Error: serde::de::StdError` is not satisfied
   --> /home/ethan/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0.0.1/src/ser/mod.rs:339:6
    |
339 | impl ser::Error for Error {
    |      ^^^^^^^^^^ the trait `serde::de::StdError` is not implemented for `ser::Error`

I was pulling the 0.0.1 crate which seems to be the only one published. Any tips?

Repository points to documentation

In Cargo.toml the repository attribute points to the documentation as follows:

repository = "https://japaric.github.io/serde-json-core/serde_json_core"

To find the repository via crates.io is not possible, and requires a Google search.

Update README

The current README should probably be updated to reflect the other rust-embedded-community repos?

Even more so, as the current Documentation link is broken after the transfer

At the same time we should probably also either fix or remove the github pages.

Release version 0.1.0

It looks like the release of this crate is blocked by @japaric not having crate ownership/permissions to the serde-json-core crate.

@dtolnay could you please grant Jorge permissions to the repo on crates.io so this can be released?

EDIT: Or alternatively, could you (dtolnay) please publish the current version of the crate? Though that would leave this crate in a similar version in the future.

Compile error: std::error::Error is not implemented

serde = { version = "1.0.106", features = ["derive"], default-features = false }
serde-json-core = "0.1.0"
error[E0277]: the trait bound `de::Error: std::error::Error` is not satisfied
  --> /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0                      .1.0/src/de/enum_.rs:16:5
   |
15 | impl<'a, 'de> de::EnumAccess<'de> for UnitVariantAccess<'a, 'de> {
   | ---------------------------------------------------------------- in this `i                      mpl` item
16 |     type Error = Error;
   |     ^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented fo                      r `de::Error`

error[E0277]: the trait bound `de::Error: std::error::Error` is not satisfied
  --> /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-json-core-0                      .1.0/src/de/enum_.rs:29:5
   |
28 | impl<'de, 'a> de::VariantAccess<'de> for UnitVariantAccess<'a, 'de> {
   | ------------------------------------------------------------------- in this                       `impl` item
29 |     type Error = Error;
   |     ^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented fo                      r `de::Error`

// etc

Can't get code to compile, do you have a working example?

I'm trying to get the following to compile but it throws an error:

[derive(Serialize, Deserialize, Debug)]
pub struct StatusResponse {
    pub pressure_psi: i32,
    pub temperature_c: i32,
    pub panic_state: bool,
    pub power_state: bool,
}

impl StatusResponse {
    pub fn serialize(&self) -> &[u8] {
        serde_json_core::to_string(self).as_ref().unwrap().as_bytes()
    }
}
error[E0282]: type annotations needed
  --> src/vpc/comms.rs:38:9
   |
38 |         serde_json_core::to_string(self).as_ref().unwrap().as_bytes()
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for `B`

I don't understand what it wants. From the examples I have found I don't need to pass anything else in to the to_string function... Does this crate work?

Support for "block-wise" serialization?

Firstly, thanks for providing this crate :)

Using the crate in the context of CoAP (the Constrained Application Protocol, RFC 7252), it would be nice if you could serialize structs in a "block-wise" manner, i.e., in chunks of a certain byte-size, where the position of the chunk "window" could be chosen arbitrarily.

This would not only allow for an easier implementation of CoAP block-wise transfer (see RFC 7959), but also save some memory on constrained devices as you would only need to have a buffer of that specific size for the result, presumably at a higher computational cost for the serialization overall, as you would need several runs for the moving window, supposing that you cannot begin where you left off after the previous one.

Do you think it would be possible to add a feature like this or accept a PR? Or would you consider it out of scope of this crate?

Incorrect serialization of bytes?

I'm extending serde-json-core for an embedded project to support pretty-formatted serialized strings, tuple variants, and struct variants. It's passing all of the existing tests, except for ser::tests::test_serialize_bytes:

# (Again, my code, not a test error with serde-json-core as-is)
thread 'ser::tests::test_serialize_bytes' panicked at 'assertion failed: `(left == right)`
  left: `"[49,46,53,54]"`,
 right: `"1.56"`', src/ser/mod.rs:1996:9

The current method in ser::Serializer just extends the underlying byte buffer:

    fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok> {
        self.extend_from_slice(v)
    }

while the Serde guide serialize_bytes should produce an array:

    // Serialize a byte array as an array of bytes. Could also use a base64
    // string here. Binary formats will typically represent byte arrays more
    // compactly.
    fn serialize_bytes(self, v: &[u8]) -> Result<()> {
        use serde::ser::SerializeSeq;
        let mut seq = self.serialize_seq(Some(v.len()))?;
        for byte in v {
            seq.serialize_element(byte)?;
        }
        seq.end()
    }

serde-json also produces a sequence of bytes. It seems like the test_serialize_bytes test shouldn't be passing as it is currently in serde-json-core. Am I missing something about the implementation specific to serde-json-core?

Float deserialization fails when no trailing characters are present

When deserializing a simple float JSON (for example, 1.0 is valid JSON), an EofWhileParsingFloat will be raised. This occurs because the float parser expects some non-numeric data after the float.

However, an EOF is considered an acceptable terminator for a floating point number. We should update float parsing to return the current string if EOF is encountered instead of throwing an error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.