Giter Site home page Giter Site logo

Comments (5)

dtolnay avatar dtolnay commented on May 10, 2024

A PR would be appreciated!

from json.

raphlinus avatar raphlinus commented on May 10, 2024

I have a minimal patch for this, but it looks like #58 is a completely different approach to fixing it. If you still want the PR to escape_bytes lemme know and I'm happy to upload it.

from json.

dtolnay avatar dtolnay commented on May 10, 2024

Thanks but based on the discussion in #58 we plan to remove escape_bytes entirely (see #60). We are waiting to hear from @erickt regarding #58.

from json.

raphlinus avatar raphlinus commented on May 10, 2024

So, looking over the discussion, I have some concerns. As a user of serde-json, I would have a very negative reaction to anything that slowed down serialization. "You should use msgpack instead of json" is already one of the major pieces of feedback I get - I depend on serializing large blocks of text performantly. I'm also not a fan of escaping things not required by the spec. To me, "other json encoders do it" is not a good enough reason. Lastly, I'm not a fan of adding complexity to deal with unicode when it's not required.

So I uploaded #65, which is what I'd personally like to see. I'm also in favor of removing escape_bytes, as I agree that it doesn't make sense (it's impossible to safely serialize binary to json), but I didn't put that in my PR because it kinda seems like a separate issue. I'd be happy to update my PR if there's agreement.

Totally up to @erickt what he prefers, but I figured I would give him the option and present my reasoning behind it.

from json.

PaulGrandperrin avatar PaulGrandperrin commented on May 10, 2024

After my PR would have merged, I was about to propose to add an option to the serializer.
This option would have been about escaping or not non-ascii characters. It can be useful to generate ascii-compatible Jsons.
In Python, this option is called ensure_ascii.
To address @raphlinus needs, we could make this option tristate like this:

enum Escaping {
    Minimal, // according to ECMA-404
    AllControlCharacters, // plus DEL and C1 characters
    AllNonAscii, // everything above 127 (C1 characters are above 127)
}

from json.

Related Issues (20)

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.