JSON in question:
{
"search_id": "",
"type": "Search.filter",
"query": "bar,club",
"params": {
"search_id": "",
"user_id": "",
"client": "ios",
"lat": 40.73199375351,
"lon": -74.00080404533901,
"radius": 20
}
}
Code to Retrieve the Data:
val json = Json.parse(new String(body))
println((json \ "search_id") + " | " + (json \ "query"))
println(json)
printing just the json JsValue prints out the entire JSON as expected. printing out the first item produces: "" | "bar,club"
Why is it maintaining the quotes from JSON formatting? That's not part of the string, it's basically saying that the content inside the quotes is a string. How do I fix this?
According to the doc, you should call .as[sometype]
(unsafe conversion) or asOpt[sometype]
(safe).
println((json \ "search_id").as[String] + " | " + (json \ "query").as[String])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With