Git Product home page Git Product logo

Comments (6)

jbrichau avatar jbrichau commented on July 17, 2024

Hey @koendehondt ,

Instead of erroring, I opted to convert the key (1 2) to a string: '#(1 2)'.
Maybe this is better than erroring, since we also convert a numeric value to a string automatically again.
What do you think?

from seaside.

koendehondt avatar koendehondt commented on July 17, 2024

I think it is strange 😄, but it is a way to make it work for every object, even if it may not be very useful. That is why I suggested to signal an error in case the Smalltalk dictionary has keys that are not supported.

The result is that the array key will be transformed into a string that does not hold a valid JSON array, because #(1 2) is not valid JSON. [1, 2] is.

from seaside.

jbrichau avatar jbrichau commented on July 17, 2024

On second thought I am not happy with it either. The serialisation to a string is different on each platform so that also makes things dodgy. But mind that the key is always a string, and its contents should not be any valid JSON serialisation.

Throwing an error is probably the best course of action. But in that case a number should also error, otherwise we are not consistent. The keys in dictionaries you want to convert must then always be strings.

This is probably not something we can ship in a bugfix release since it changes the semantics. I'll have to see...

from seaside.

koendehondt avatar koendehondt commented on July 17, 2024

Throwing an error is probably the best course of action. But in that case a number should also error, otherwise we are not consistent.

I agree.

This is probably not something we can ship in a bugfix release since it changes the semantics.

Indeed.

from seaside.

jbrichau avatar jbrichau commented on July 17, 2024

I updated #1368
It introduces a flag to make the JSON writer error when the keys of a dictionary are not strings.

from seaside.

koendehondt avatar koendehondt commented on July 17, 2024

OK. Thanks @jbrichau.

from seaside.

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.