PHP: How to json encode of hindi language in response -
i working translation api here issue. using json in response , when json_encode of hindi out "\u092f\u0939 \u0915\u093e\u0930 \u0939\u0948"
my code given below
$data = array(); $data['hindi'] = 'यह कार है'; $data['english'] = 'this car'; echo json_encode($data); die;
and response
{"hindi":"\u092f\u0939 \u0915\u093e\u0930 \u0939\u0948","english":"this car"}
this correct json , when display in browser , / or parse it, result in object correct keys , values:
var json_string = '{"hindi":"\u092f\u0939 \u0915\u093e\u0930 \u0939\u0948","english":"this car"}', json = json.parse(json_string); // or directly: var json2 = {"hindi":"\u092f\u0939 \u0915\u093e\u0930 \u0939\u0948","english":"this car"}; console.log(json_string); console.log(json); console.log(json2); document.write(json_string); document.write('<br>'); document.write(json.hindi); document.write('<br>'); document.write(json2.hindi);
Comments
Post a Comment