0

I have a string, which contains valid json. I'd like to add that json as a JField in a larger json4s AST I'm building, but it'd be nice to avoid having to parse the json into an AST first. I trust it.

// this would work, but I'd prefer to avoid parsing something I 
// happen to already know contains valid json
val rawJsonStr = "..."
val spliced = JField("foo", parse(rawJsonStr))

Is there a way beyond building the AST, converting it to json, then doing text manipulation?

randomstatistic
  • 800
  • 5
  • 11

1 Answers1

0

I tried to do the same. After several attempts I realized that this was not a good idea.

Since the second element of JField("foo", _) is supposed to be a JValue. When I put a string in it ended up being an escaped string.

Maybe you can get around this.

Sami Badawi
  • 977
  • 1
  • 10
  • 22