0

How to extract decode JSON from REDCAP Array with PHP

Hallo there, I have an JSON Export from a REDCAP and it started as a nested ARRAY. I use json_decode, but when I print the result I get ERROR. Here is the Array: [{"record_id":"13","lastname":"Mustermann","first_name":"Json","dob":"1948-10-12","case_number":"1366613"}] My Code is: $deco = json_decode($json); print $deco; This line gives an error. What am I doing wrong?! Thank you

30th Mar 2020, 10:12 PM
pap
pap - avatar
4 Antworten
+ 2
If you decode to object, try this: $a = $jsonObj[0]->record_id; If array: $a = $jsonArr[0]["record_id"];
31st Mar 2020, 9:56 AM
Hello World
Hello World - avatar
+ 1
Hi, print and echo can't display array or object. Try to use debug function, like print_r or var_dump. Also, please note that json_decode returns object. If you want to get result as array, you can pass second argument as true.
31st Mar 2020, 12:32 AM
Hello World
Hello World - avatar
0
Hello World thank you! Now I want to assign some data from this jason to variables. like $a = $demo{‘dob’}; and then echo $demo; This dost work either. How can I assign?
31st Mar 2020, 6:17 AM
pap
pap - avatar
0
Hello World thank you! it works!
31st Mar 2020, 11:23 AM
pap
pap - avatar