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

WebSharper.Json: handle obj #921

Tarmil opened this Issue Mar 10, 2018 · 0 comments


2 participants

Tarmil commented Mar 10, 2018

Currently the behavior for JSON serialization is inconsistent between the client and the server. Considering the following code:


On the server, it throws an exception; and on the client, it doesn't throw but returns a useless empty object, result of calling the obj constructor.

There are two possibilities to have more consistent behavior:

  • Don't try to implement obj deserialization, and throw a compile-time error when this is called from the client-side.

  • Do implement obj deserialization, in which case we have to decide what the behavior should be.

    • on the client side: presumably just return the parsed value (ie one of: null, a boolean, a string, a number, an array or a plain object).
    • on the server side:
      • null, boolean, string would return a value of the corresponding type.
      • number: should it always return float, or should it return int if the value is an integer and float otherwise?
      • array: presumably return a recursively parsed obj[]?
      • object: presumably return a recursively parsed Dictionary<string, obj>?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment