English 中文(简体)
释放这名JSON档案结构
原标题:Parsing this JSON file structure

i 拥有以json格式编排的内部数据格式档案:

{
   "data": 

     {

   "users": [


    {

        "ragione_sociale": "",
        "nome": "Annamaria Zaccariello",
        "indirizzo": "",
        "cap": "",
        "citta": "",
        "provincia": "",
        "telefono1": "",
        "telefono2": "",
        "fax": "",
        "cellulare": "",
        "codice_fiscale": "",
        "newsletter": "1",
        "sesso": "",
        "username": "annamaria.zaccariello@libero.it",
        "scadenza_tessera": "09/08/2012",
        "tipo_tessera": "Red Carpet",
        "stato_tessera": "0",
        "user_id": "1",
        "punti": "0"
    },
    {

        "ragione_sociale": "",
        "nome": "Debora Chessa",
        "indirizzo": "",
        "cap": "",
        "citta": "",
        "provincia": "ge",
        "telefono1": "",
        "telefono2": "",
        "fax": "",
        "cellulare": "3494339496",
        "codice_fiscale": "",
        "newsletter": "1",
        "sesso": "F",
        "username": "debora_c85@hotmail.it",
        "scadenza_tessera": "05/10/2012",
        "tipo_tessera": "Membership",
        "stato_tessera": "0",
        "user_id": "968",
        "punti": "0"
    } 
    ]
     }

}

我需要把所有用户一对一对一对一,从中提取一些信息“无”、“用户名称”、“爱沙尼亚”、“爱沙尼亚”、“芬兰”、“芬兰”、“芬兰”、“芬兰”、“punti”、“provincia”、“细胞”

Anyone can paste PHP code to do this operation ?

增 编

最佳回答

如果你在<条码>上避开了你的 j子,则 你们将能够做这样的事情:

$myjson = <<< EOT
{
   "data": 

     {

   "users": [


    {

        "ragione_sociale": "",
        "nome": "Annamaria Zaccariello",
        "indirizzo": "",
        "cap": "",
        "citta": "",
        "provincia": "",
        "telefono1": "",
        "telefono2": "",
        "fax": "",
        "cellulare": "",
        "codice_fiscale": "",
        "newsletter": "1",
        "sesso": "",
        "username": "annamaria.zaccariello@libero.it",
        "scadenza_tessera": "09/08/2012",
        "tipo_tessera": "Red Carpet",
        "stato_tessera": "0",
        "user_id": "1",
        "punti": "0"
    },
    {

        "ragione_sociale": "",
        "nome": "Debora Chessa",
        "indirizzo": "",
        "cap": "",
        "citta": "",
        "provincia": "ge",
        "telefono1": "",
        "telefono2": "",
        "fax": "",
        "cellulare": "3494339496",
        "codice_fiscale": "",
        "newsletter": "1",
        "sesso": "F",
        "username": "debora_c85@hotmail.it",
        "scadenza_tessera": "05/10/2012",
        "tipo_tessera": "Membership",
        "stato_tessera": "0",
        "user_id": "968",
        "punti": "0"
    } 
    ]
     }

}
EOT;

$obj=json_decode($myjson);
foreach($obj->data->users as $user){
        echo $user->username;
}

但是,如果插入无效的JSON$obj,则将改为null。 这不属于 s。

问题回答

暂无回答




相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

How to get instance from string in C#?

Is it possible to get the property of a class from string and then set a value? Example: string s = "label1.text"; string value = "new value"; label1.text = value; <--and some code that makes ...

XML DOM parsing br tag

I need to parse a xml string to obtain the xml DOM, the problem I m facing is with the self closing html tag like <br /> giving me the error of Tag mismatch expected </br>. I m aware this ...

Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

Locating specific string and capturing data following it

I built a site a long time ago and now I want to place the data into a database without copying and pasting the 400+ pages that it has grown to so that I can make the site database driven. My site ...

热门标签