json.net 有关键方法吗? [英] json.net has key method?

查看:6
本文介绍了json.net 有关键方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的回复有关键错误",我需要处理错误并显示警告框.

If my response has key "error" I need to process error and show warning box.

json.net 中是否存在haskey"方法?喜欢:

Is there "haskey" method exists in json.net? Like:

var x= JObject.Parse(string_my);
if(x.HasKey["error_msg"])
    MessageBox.Show("Error!")

推荐答案

只需使用 x["error_msg"].如果该属性不存在,则返回 null.

Just use x["error_msg"]. If the property doesn't exist, it returns null.

这篇关于json.net 有关键方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆