These are chat archives for mdedetrich/scala-json-ast

28th
May 2016
Matthew de Detrich
@mdedetrich
May 28 2016 08:22
@OlivierBlanvillain There is a version of play that uses scala json ast
Olivier Blanvillain
@OlivierBlanvillain
May 28 2016 08:28
@mdedetrich Thanks, will look into that!
Regarding js/Scala.js interop I don't understand why you annotated everything with @JSExport, I think function from and to scala.scalajs.js.Dynamic would be more useful. TBH I don't see myself going to my front-end team ask them to write something like the following in their JS code to interop with my Scala.js:
var jObjectWithBoolAndNumberAndNull = new scala.json.ast.JObject({
    "someString" : jArray,
    "someBool" : scala.json.ast.JTrue(),
    "someNumber" : new scala.json.ast.JNumber(324324.324),
    "nullValue": scala.json.ast.JNull()
});
Matthew de Detrich
@mdedetrich
May 28 2016 08:50
@OlivierBlanvillain I did it because I think some people would find it useful, and also you don’t lose anything by doing it
If enough people ask to remove it, I will do it
Olivier Blanvillain
@OlivierBlanvillain
May 28 2016 09:10

@mdedetrich I see. Do you think something like the following would have it's place in js/JValue.scala:?

object JValue {
  @JSExport
  def from(j: js.Dynamic): JValue = ???

  @JSExport
  def to(j: JValue): js.Dynamic = ???
}

I going to write it anyways, would be happy to contribute a PR :smile:

Matthew de Detrich
@mdedetrich
May 28 2016 09:56
@OlivierBlanvillain That should already exist
Oh wait, you mean going from js.Dynamic to a JValue in Scala.js
If you are going to do that, its probably best to follow the same pattern you see here
Olivier Blanvillain
@OlivierBlanvillain
May 28 2016 09:58
You mean implementing it directly on the ADT?
That same style
Olivier Blanvillain
@OlivierBlanvillain
May 28 2016 10:03
Yeah that will do for the to part, from probably needs to be static