- http://php.net/manual/en/function.json-decode.php
- http://nitschinger.at/Handling-JSON-like-a-boss-in-PHP/
Last active
March 20, 2016 04:51
-
-
Save qgp9/ec9ffb90422bc5e11a79 to your computer and use it in GitHub Desktop.
언어별 json 데이터 다루기 예제
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$json = json_decode(file_get_contents("test.json"),true); | |
#print_r( $json ); | |
print( "# Message = ". $json["message"]."\n" ); | |
print( "# Code = ". $json["code"]."\n" ); | |
$info = $json['info']; | |
foreach ( $info as $aUser ){ | |
print( "# aName = ".$aUser['aName']."\n" ); | |
foreach ( $aUser['bList'] as $bUser ){ | |
print( "\t\tbName = ".$bUser['bname']."\n" ); | |
} | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"message": "OK", | |
"code": "000", | |
"info": [ | |
{ | |
"aName": "홍길동", | |
"aCode": "A11", | |
"bList": [ | |
{ | |
"bid": "A12", | |
"bname": "홍길동_2" | |
}, | |
{ | |
"bid": "A13", | |
"bname": "홍길동_3" | |
} | |
] | |
}, | |
{ | |
"aName": "나동수", | |
"aCode": "A21", | |
"bList": [ | |
{ | |
"bid": "A22", | |
"bname": "나동수_2" | |
}, | |
{ | |
"bid": "A23", | |
"bname": "나동수_3" | |
} | |
] | |
}, | |
{ | |
"aName": "김영철", | |
"aCode": "A31", | |
"bList": [ | |
{ | |
"bid": "A32", | |
"bname": "김영철_2" | |
}, | |
{ | |
"bid": "A33", | |
"bname": "김영철_3" | |
}, | |
{ | |
"bid": "A34", | |
"bname": "김영철_4" | |
}, | |
{ | |
"bid": "A35", | |
"bname": "김영철_5" | |
}, | |
{ | |
"bid": "A36", | |
"bname": "김영철_6" | |
} | |
] | |
}, | |
{ | |
"aName": "이순신", | |
"aCode": "A41", | |
"bList": [ | |
{ | |
"bid": "A42", | |
"bname": "이순신_2" | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment