New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON support. #28

Closed
wants to merge 4 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@rebolek

rebolek commented Apr 3, 2017

No description provided.

@dockimbel

This comment has been minimized.

Member

dockimbel commented Apr 4, 2017

>> json/decode {{"key": null}}
== #(
)

Is it the desired behavior?

@rebolek

This comment has been minimized.

rebolek commented Apr 4, 2017

Can we get fully compatible JSON loader/saver in Red? IMO no, we do not have datatype that is fully compatible with JS' object - map! cannot store none and object! cannot store keys that are not word!s.

Is this good enough loader/saver? I think that it is good enough compromise. It is probably a question of preferences.

@dockimbel

This comment has been minimized.

Member

dockimbel commented Apr 4, 2017

we do not have datatype that is fully compatible with JS' object

hash! should work fine for loading JS objects, though, its API is not enforcing a key/value model with no duplicates, so it would require extra effort from users when building one fully compatible with JSON (though the JSON encoder could just error out on duplicate keys).

Partial JSON support is not "JSON support". It's probably good enough for a personal project, but a JSON library cannot decently only partially support it (and that's not a matter of preferences, but matter of not deceiving the users).

@rebolek

This comment has been minimized.

rebolek commented Apr 4, 2017

Hm. What about having two modes (for decoder), strict that will return hash! and relaxed, that will return map! which would be fine in most cases?

@dockimbel

This comment has been minimized.

Member

dockimbel commented Apr 4, 2017

We need a working solution out of the box, the user should not have to think if its JSON input has null values or not.

@rebolek

This comment has been minimized.

rebolek commented Apr 4, 2017

Ok, so you prefer it to return hash! and conversion to map! should be done by user manually, if I understand it?

@dockimbel

This comment has been minimized.

Member

dockimbel commented Apr 4, 2017

No, JSON being such a big standard, needs a great support in Red. It is not something that should be rushed, but designed properly, which means, first solving the different problems, finding the best possible solutions.

@rebolek

This comment has been minimized.

rebolek commented Apr 4, 2017

OK, I will delete the pull request then.

@rebolek rebolek closed this Apr 4, 2017

@xaduha

This comment has been minimized.

xaduha commented Jun 16, 2018

@rebolek @dockimbel

Hi, I noticed there's https://github.com/red/wallet/blob/master/libs/JSON.red now, should it be here too? Or is it going to be a part of main repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment