Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a JSON JString value to an ordinary String in Lift?

Tags:

Having a jString : JString value holding an "abc" string inside I get "JString(abc)" : String if I call jString.toString. How do I get "abc" : String instead?

like image 778
Ivan Avatar asked Oct 16 '11 02:10

Ivan


1 Answers

To extract a value from JValue you can use any method described here: What is the most straightforward way to parse JSON in Scala?

For instance:

json.extract[String] 

You can use 'render' function to convert any JValue to printable format. Then either 'pretty' or 'compact' will convert that to a String.

compact(render(json)) 

or

pretty(render(json)) 
like image 63
Joni Avatar answered Oct 03 '22 02:10

Joni