我有一个JSON字符串。
的Json
未决:
"{"result":"success","message":"License key details retrieved.","status":"pending","max_allowed_domains":"1","email":"","registered_domains":[],"date_created":"","date_renewed":"","date_expiry":""}"
主动:
"{"result":"success","message":"License key details retrieved.","status":"active","max_allowed_domains":"1","email":"","registered_domains":[],"date_created":"","date_renewed":"","date_expiry":""}"
无效:
"{"result":"error","message":"Invalid license key"}"
谢谢!
答案 0 :(得分:0)
如果您使用的是PHP,请首先在包含JSON字符串的变量上使用。
之后,您应该能够检查数组中的值。
一个松散的例子:
$arr = json_decode($json_string);
if($arr['result'] == "error"){
echo "Invalid";
}elseif($arr['result'] == "success" && $arr['status'] == "pending"){
echo "Pending";
}elseif($arr['result'] == "success" && $arr['status'] == "active"){
echo "Active";
}else{
echo "what if it's something else??";
}