Skip to content

Conversation

rebolek
Copy link

@rebolek rebolek commented Apr 3, 2017

No description provided.

@dockimbel
Copy link
Member

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

Is it the desired behavior?

@rebolek
Copy link
Author

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
Copy link
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
Copy link
Author

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
Copy link
Member

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
Copy link
Author

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
Copy link
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
Copy link
Author

rebolek commented Apr 4, 2017

OK, I will delete the pull request then.

@rebolek rebolek closed this Apr 4, 2017
@xaduha
Copy link

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants