JsonParser.parse unquote behavior

30 views
Skip to first unread message

Alan Li

unread,
Jul 15, 2015, 5:58:30 PM7/15/15
to lif...@googlegroups.com
Hello lift devs,

I'm seeing the following behavior using liftweb-json where JsonParser.parse() output does not accurately represent the input json in our application, and I've narrowed it down to the following simplified case. And I see this in both lift-json 2.6 and 2.6.2. I believe this is due to the unquote() functionality within JsonParser class.

object TestLift {

  def main(args: Array[String]) {

  val jsonString = "{\"add\":[{\"name\":\"foo \\uffff bar\"}]}"

    println(jsonString)

  val jsonResponse = parse(jsonString)

    println(jsonResponse)

  }

}


Here is the output:

{"add":[{"name":"foo \uffff bar"}]}

JObject(List(JField(add,JArray(List(JObject(List(JField(name,JString(foo ? bar))))))))) 

The output that I would expect is:

 {"add":[{"name":"foo \uffff bar"}]}
JObject(List(JField(add,JArray(List(JObject(List(JField(name,JString(foo \uffff bar))))))))) 

 Thanks, Alan

Matt Farmer

unread,
Jul 16, 2015, 7:19:17 PM7/16/15
to Lift
Hey Alan,

Thanks for the note. It looks like Java is trying to interpret “\uffff” as a Unicode code point. This definitely looks like a bug to me, but I guess there’s a possibility this behavior is intentional?

Unless this looks Good™ to anyone, I can file a bug and take a look at fixing it.


Matt Farmer Blog | Twitter

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Antonio Salazar Cardozo

unread,
Jul 17, 2015, 2:31:10 PM7/17/15
to lif...@googlegroups.com, ma...@frmr.me
Yeah, the key here is that the \ is escaped, but it's being treated as if it's not
escaped. I'd call it a bug for sure. Feel free to take it! :) If you want to have more
fun with Unicode escaping and JSON, btw, there's also this guy: https://github.com/lift/framework/issues/1676
Thanks,
Antonio
Reply all
Reply to author
Forward
0 new messages