從其他 api 拿回來(如: URLConnection)的 JSON字串可大略分為兩種
1.
String result = [
"_id": "123",
"username": "Andro"
]
[AJAX] Echo PHP Array by JSON
雖然 jQuery AJAX 中,要 echo string 回去,
但天真地試圖傳 array 回去,會cannot convert an array to a string
所以請使用
但天真地試圖傳 array 回去,會cannot convert an array to a string
所以請使用
- In PHP:In JavaScript:
[python] Parsing, Decoding, Read json
Referencing: parsing json python, python json decoding
These two article should be clear enough! 這兩篇應該就蠻清楚的了!
* JSON objects behave like dictionaries, JSON format is a list containing objects
-> access object by json[object], and len(json) would get the length of json
-> using iterator on a dictionary, hence can be used on json format.
get keys by simple dict.keys(), get values by simple dict.values()
http://www.python.org/dev/peps/pep-3106/
These two article should be clear enough! 這兩篇應該就蠻清楚的了!
* JSON objects behave like dictionaries, JSON format is a list containing objects
-> access object by json[object], and len(json) would get the length of json
-> using iterator on a dictionary, hence can be used on json format.
get keys by simple dict.keys(), get values by simple dict.values()
http://www.python.org/dev/peps/pep-3106/
訂閱:
文章
(
Atom
)