Giter Club home page Giter Club logo

Comments (1)

NathanReb avatar NathanReb commented on July 26, 2024

Thanks for reporting this and for taking the time to look into the solutions and there pros and cons! Both seem great!

Indeed the prefix thing would be preferable to the attribute solution. It's both easier to use and to implement as the attribute would be attached to the expression bound to the field (nothing impossible to deal with but slightly more tedious).

As you point out there's a risk that it prevents users from writing fields that starts with an underscore. To solve that, what would you think about the following rewriting rule: If the field name starts with an underscore, just remove it unconditionally and leave the rest unchanged.

That way, you should still be able to write JSON field that starts with _ by simply adding an extra leading _, e.g. __secret_field would be rewritten to _secret_field.

The attribute being backward compatible is good indeed but I don't think it would hurt to release a new major version. Actually since we're adding breaking changes, we could also use this occasion to rename the package to ppx_json since it's not yojson specific anymore thanks to your previous contribution!

I think a PR for the rewriting would be welcome as it is bound to get in at some point anyway. I might implement the attribute based solution as well and cut a release with it before to allow for a smooth transition.

from ppx_yojson.

Related Issues (9)

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.