我正在尝试从我的 CRM 跑道中进行的 API 调用中提取所有填充的数据...
API调用响应如下:
{
"status": {
"version": "1.0.0",
"code": 0,
"msg": "SuccessWithResult",
"total": 1,
"page": 1,
"pagesize": 10,
"transactionID": "ba31a62303e76d49b2063e94e2972bc6"
},
"property": [
{
"identifier": {
"Id": 34476108,
"fips": "48201",
"apn": "1288930010042",
"attomId": 34476108
},
"lot": {
"lotnum": "42",
"lotsize1": 0.2735078,
"lotsize2": 11914,
"poolind": "YES"
},
"area": {
"blockNum": "1",
"loctype": "VIEW - NONE",
"countrysecsubd": "Harris",
"countyuse1": "1001 ",
"muncode": "HA",
"munname": "HARRIS",
"subdname": "BLACKHORSE RANCH SOUTH SEC 6",
"taxcodearea": "40"
"legal1": "BLACK HORSE RANCE LOT 14 BLOCK 12 USA"
等等
我已尝试使用以下代码来仅提取法律描述,但它在我的 crm 注释中返回整个 API 响应。我正在尝试获取单独列出的所有数据点。
preg_match_gf("/legal1\.\:\s\/(.*)/ism",[(Variable) PropertyDetails], 1)
非常感谢任何建议或见解!!
谢谢你,
科迪
在变量块中使用
json_decode
来提取值而不是正则表达式。
例如,如果总是只有一个属性:
json_decode([(Variable) PropertyDetails], true)["property"][0]["area"]["legal1"]
例如,如果可以有多个属性:
foo(); function foo(){
$legal = [];
$data = json_decode([(Variable) PropertyDetails], true);
foreach ( $data["property"] as $property ) {
$legal[] = $property["area"]["legal1"];
}
return implode(", ", $legal);
}