This post triggered a discussion between AndrĂ¡s and me about how to best handle arbitrarily-shaped JSON in WebSharper.Json, which I summarized in these two GitHub issues where you're welcome to participate:

  • #921 is based on my other comment here, about how to best handle obj.
  • #922 is about providing a better typed option for arbitrary JSON.
By on 3/10/2018 2:45 AM ()

Right, we don't really have a consistent story for the obj type. On the server it throws an exception, whereas on the client it doesn't throw but it returns a fairly useless empty object value (basically the result of calling the client-side constructor for obj). That's clearly not a good state of affairs.

I'm not quite sure what would be an expected behavior though, but I think it's a good discussion to open.

I guess the client should just return the value as is. But what about the server, how should it handle the different shapes it could encounter? Should it always treat numbers as float, or return int if it can parse it as one? Should it translate arrays to obj[] and objects to Dictionary<string,obj>?

By on 3/10/2018 1:39 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us
Built with WebSharper