0

这是我的代码 iv 需要转换 PHP 代码

{  "Parameter": {  "LookupName": "EmailAddress",
            "LookupValue": "asdasd@fgdfg.dfg"
        },
        "Columns": {  "Include_CSV": "ProspectID",
            "FirstName": "",
            "LastName": "",
            "EmailAddress": ""
        },
        "Sorting": {   "ColumnName": "FirstName",
            "Direction": "1"
        },
        "Paging": { "Offset": 0,
            "RowCount": 200
        }
    }

用于将详细信息发送到 api。

4

3 回答 3

1

尝试这个,

<?php
    $json='{"Parameter": {  "LookupName": "EmailAddress",
            "LookupValue": "asdasd@fgdfg.dfg"
        },
        "Columns": {  "Include_CSV": "ProspectID",
            "FirstName": "",
            "LastName": "",
            "EmailAddress": ""
        },
        "Sorting": {   "ColumnName": "FirstName",
            "Direction": "1"
        },
        "Paging": { "Offset": 0,
            "RowCount": 200
        }
    }';
    $array = json_decode($json,true);
?>

读取json-decode

于 2013-08-23T12:08:00.663 回答
1

你需要这样的东西:

$json = '{  "Parameter": {  "LookupName": "EmailAddress",
            "LookupValue": "asdasd@fgdfg.dfg"
        },
        "Columns": {  "Include_CSV": "ProspectID",
            "FirstName": "",
            "LastName": "",
            "EmailAddress": ""
        },
        "Sorting": {   "ColumnName": "FirstName",
            "Direction": "1"
        },
        "Paging": { "Offset": 0,
            "RowCount": 200
        }
    }';

$array = json_decode($json, true);

var_dump($array);

输出

array (size=4)
  'Parameter' => 
    array (size=2)
      'LookupName' => string 'EmailAddress' (length=12)
      'LookupValue' => string 'asdasd@fgdfg.dfg' (length=16)
  'Columns' => 
    array (size=4)
      'Include_CSV' => string 'ProspectID' (length=10)
      'FirstName' => string '' (length=0)
      'LastName' => string '' (length=0)
      'EmailAddress' => string '' (length=0)
  'Sorting' => 
    array (size=2)
      'ColumnName' => string 'FirstName' (length=9)
      'Direction' => string '1' (length=1)
  'Paging' => 
    array (size=2)
      'Offset' => int 0
      'RowCount' => int 200

访问它

echo $array['Parameter']['LookupValue']; // Returns asdasd@fgdfg.dfg
于 2013-08-23T12:08:38.747 回答
0
$array = json_decode($_POST['jsonvalue']);
于 2013-08-23T12:04:04.523 回答