Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 具有多个键值JSON对级别的PHP错误_C#_Php_Mysql_Json - Fatal编程技术网

C# 具有多个键值JSON对级别的PHP错误

C# 具有多个键值JSON对级别的PHP错误,c#,php,mysql,json,C#,Php,Mysql,Json,我正在使用从C应用程序进入php的多个级别的JSON数据,如下所示: public class User_Group { public int ID_UserGroup { get; set; } public string Name_UserGroup { get; set; } public int UserID { get; set; } } public class User_Role { public int ID_User { get; set; }

我正在使用从C应用程序进入php的多个级别的JSON数据,如下所示:

public class User_Group
{
    public int ID_UserGroup { get; set; }
    public string Name_UserGroup { get; set; }
    public int UserID { get; set; }
}
public class User_Role
{
    public int ID_User { get; set; }
    public string Role_User { get; set; }
    public string User_Role_Description { get; set; }
    public List<User_Group> UserGroup { get; set; }
}

public class Stand_Orte
{
    public int ID { get; set; }
    public string Bezeichnung { get; set; }
    public List<Modul> modul { get; set; }
}

public class Modul
{
    public string ID { get; set; }
    public string Seriennummer { get; set; }
    public string Bezeichnung { get; set; }
    public string StandortID { get; set; }
    public List<Mess_Kanal> MessKanal { get; set; }
}

public class Mess_Kanal
{
    public string ID { get; set; }
    public string ModulID { get; set; }
    public List<LogMess_Daten> LogMessDaten { get; set; }
}

public class LogMess_Daten
{
    public string KanalID { get; set; }
    public string Zeitstempel { get; set; }

}


public class RootObject
{
    public int ID_Project { get; set; }
    public string Name_Project { get; set; }
    public int Receiver_ID { get; set; }
    public string Receiver_Name { get; set; }
    public int UserID { get; set; }
    public User_Role UserRole { get; set; }
    public Stand_Orte Standorte { get; set; }
}
我在访问第三级数据元素时遇到问题。 例如,我能够获得Upil Project->Stand_Orte->Modul的值。但在那个之后,项目->站立->模块->MessKanal在PHP中抛出了一个错误,因为它试图获取非对象的属性。 我尝试了以下方法:

$phpArray['project']->Standorte[0]->module[0]->MessKanal[0]->ID $MessKanal=$phpArray->Standorte->module->MessKanal; 然后使用foreach$messkanals作为$messkanal将messkanal数据插入MYSQL。 它分别给出了以下错误

无法将stdClass类型的对象用作数组 正在尝试获取非对象的属性 有人知道吗

谢谢,
Revathy

您是否使用json_decode来解码您的json?如果是,您是否指定了第二个参数“assoc”,即json_decode$json,true assoc如果为true,返回的对象将转换为关联数组。我尝试使用assoc,但没有使用assoc。使用assoc,我无法访问此处的第一级项目。没有assoc,我无法访问第三级-MessKanal,此处。