"; $json 2_string= ' {" tsnpm": { "name": "#特色牛排面 #", "Score": "(4.7 points)", "Price": "¥9.0", "description": "Full of rivalry, slightly spicy and smooth." " }, " Mnnrm ": { " name ":" #: Minnan beef Noodle # "," Score ":" (4.8 points) "," Price ":" ¥8.5 "," description ":" Smooth and delicious, memorable. " " }, " HXNCM ": { " name ":" #红烧牛杂面 # "," Score ":" (4.8 points) "," Price ":" ¥8.0 "," description ":" Fragrant and seductive, five miscellaneous! " " }, " GWCSGJF ": { " name ":" #广味叉烧盖浇饭 # "," Score ":" (4.7 points) "," Price ":" ¥8.5 "," description ":" Nourishing, nourishing stomach, delicious, energetic " }, "Xhscd": { "name": "#西红柿炒蛋 #", "Score": "(4.8 points)", "Price": "¥2.0", "description": "Pleasant taste, inexpensive!" " }}'; $obj =json_decode ($json 2_string,true); if (!is_array ($obj)) Die (' no successful '); Print_r ($obj); Echo '
'. $obj [' tsnpm '] [' name '];? >
When I parse the $json2_string string can parse the success, but I parse from the file to get the string $json_string when it is not resolved, ask the master How to solve this?
Reply to discussion (solution)
Is your JSON file a UTF-8 format with a BOM header? Remove BOM head look down
Which one is $json2_string, put it separately.
./js/recommendmenu.json open it up with a connection, okay?
Echo Print_r ($json _string,true);
Just print the string that was read to
Don't see Json_decode ($json _string) in your code, how do you know you can't parse it?
$obj =json_decode ($json 2_string,true);
if (!is_array ($obj)) Die (' no successful ');
A hint?
Is your JSON file a UTF-8 format with a BOM header? Remove BOM head look down
The first floor is right, my code is the utf-8 format of the BOM header, minus the same as the string
./js/recommendmenu.json open it up with a connection, okay?
Yes, on line 39th.
Is the first floor of the problem that I use the wrong code, thank you for your enthusiastic reply