using net.liftweb.json what is the difference \ and \ operators when parsing json ?
import net.liftweb.json._ val parsed = JsonParser.parse(jsonString) val name = parsed.\("firstName") val userId = parsed.\\("userId")
"\\" will extract the value even if it's present within nested json whereas "\" will extract the value only if present as a top-level attribute.
Consider this json
val json = """{"nested1":{"nested2": {"myKey":"myValue"}}}""" val jsonMsg = parse(json)
In this case
(jsonMsg \ "myKey").values
retruns None
where as
(jsonMsg \\ "myKey").values
returns myValue
"\\" will extract the value even if it's present within nested json whereas "\" will extract the value only if present as a top-level attribute.
Consider this json
In this case
retruns None
where as
returns myValue