我有一个结果为JSON字符串
[{"GROUP_MOD_ID":"G02","ADD":1,"EDIT":0,"DEL":1,"VIEW":null,"UP":1,"PRINT":null,"ADMIN":null,"MOD":null,"ADD-AD":null,"EDIT-AD":null,"DEL-AD":null,"VIEW-AD":null}]
好的,我想让名字和价值做点什么
public static bool Check(string group_mod_id)
{
var obj = GroupModBus.GetGroupModFunc(group_mod_id);
if (obj != "[]")
{
if (obj.Contains["ADD"]=="1")
{
//do something
return true;
}
}
else
return false;
}
收到错误Error 1 Cannot apply indexing with [] to an expression of type 'method group'
注意:在这里是动态数据,而不是在实例中。通常,如果在一个实例中的数据,我可以像这样使用
public class EXAMPLE
{
public string ADD { get;set;}
public string EDIT {get;set;}
///etc....
}
///using as
if (obj.ADD =="1")
{
//do something
return true;
}
我想我应该将JSON字符串转换为数组,然后获取名称并获取价值。你这么认为吗?