java 迭代器遍历json
JSONObject jsonObject = new JSONObject(jsonString);
Iterator iterator = jsonObject.keys();
while(iterator.hasNext()){
key = (String) iterator.next();
value = jsonObject.getString(key);
}
js遍历json
- <script type="text/javascript">
- function text(){
- var json = {"options":"[{/"text/":/"王家湾/",/"value/":/"9/"},{/"text/":/"李家湾/",/"value/":/"10/"},{/"text/":/"邵家湾/",/"value/":/"13/"}]"}
- json = eval(json.options)
- for(var i=0; i<json.length; i++)
- {
- alert(json[i].text+" " + json[i].value)
- }
- }
- </script>