GithubHelp home page GithubHelp logo

Convert atoms to strings about jsx HOT 6 CLOSED

talentdeficit avatar talentdeficit commented on August 15, 2024
Convert atoms to strings

from jsx.

Comments (6)

talentdeficit avatar talentdeficit commented on August 15, 2024

jsx:encode([{foo, <<"bar">>}]) will work but i'm hesitant to allow atoms in string positions because the atoms true, false and null have special meaning as the second value of a 2-tuple. i like simple apis so i don't like exceptions like 'any atom EXCEPT true, false and null will be converted to a json string'

while i agree it's obnoxious that jsx can't just do the obvious thing here it's more obnoxious that people are going to generate json that they expect will be {"key": "true"} but get {"key": true}

from jsx.

dvv avatar dvv commented on August 15, 2024

oh, i see. i didn't manage to reliably understand the last sentence, sorry. i believed things would be ok if we just excluded these three terminal cases from any further conversion.

from jsx.

talentdeficit avatar talentdeficit commented on August 15, 2024

i understand it seems stupid to not just make an exception for true, false and null but it's simpler to explain 'all strings must be binaries' than 'all strings must be binaries or atoms unless they are the atoms true, false or null'. i think when dealing with api's you should always do the simplest thing possible

from jsx.

dvv avatar dvv commented on August 15, 2024

i see. another attempt and i'll retire :) as you're perfectly right on API.

it seems to me like a matter of wording. 'All binaries are converted to strings. All atoms except well-known true/false/null are converted to strings.' seems perfect to me.

my point is that the ability of encoding almost anything with least surprise and without friction is the killer feature of jsx. maybe an option to trigger said conversion?

thank you

from jsx.

talentdeficit avatar talentdeficit commented on August 15, 2024

i think most users don't really read documentation. they read just enough to think they know what they are doing and then go do it. i'm sorry but i don't think allowing atoms in positions where utf8 binaries are expected is worth it

from jsx.

dvv avatar dvv commented on August 15, 2024

np :)

from jsx.

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.