i have difrent string json type egz formats in line
{"env":"stato","usc":"00000000","isc":"000100","sn":"0120xxxxmacxxx"}
{{"cmd":"stat"},{"usc":"00000000",{"isc":"1001000"}},"sn":"0120xxxxmacxxx"}
{{"cmd":"status","usc":"00000000","isc":"1110001"},"sn":"0120xxxxmacxxx"}
{'stat':'dev',{data:['usc':'00000000','isc':'10010001']},'sn':'0120xxxxmacxxx'}
need single regex by get only numbers 0-1 format in quotes after "isc":"NEED THIS NUMBERS ONLY" in single php regex for all formats.
egs
$json = '{"env":"stato","usc":"00000000","isc":"00010000","sn":"0120xxxxmacxxx"}';
$find = "isc";
function find_data($find,$json){
preg_match('/("'.$find.'":"[^"]*"|^[^"]*$)/i', $json, $ref, PREG_OFFSET_CAPTURE);
return $ref;
}
json loop solution does not come! json search can only be accepted on one line of code,
I have limited computing and memory resources in atmega 16
thx for help
>Solution :
$json = '{"env":"stato","usc":"00000000","isc":"00010000","sn":"0120xxxxmacxxx"}';
$arr = json_decode($json);
$isc = $arr->isc;
print_r($isc); // Prints: 00010000