Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 net.liftweb.json 解析 json 时 \ 和 \ 运算符有什么区别?
import net.liftweb.json._ val parsed = JsonParser.parse(jsonString) val name = parsed.\("firstName") val userId = parsed.\\("userId")
“\\” 将提取该值,即使它存在于嵌套的 json 中,而“\” 将仅在作为顶级属性存在时提取该值。
考虑这个json
val json = """{"nested1":{"nested2": {"myKey":"myValue"}}}""" val jsonMsg = parse(json)
在这种情况下
(jsonMsg \ "myKey").values
返回 无
然而
(jsonMsg \\ "myKey").values
返回我的值