{
"pageInfo": {
"pageName": "abc",
"pagePic": "http://example.com/content.jpg"
},
"posts": [
{
"post_id": "123456789012_123456789012",
"actor_id": "1234567890",
"picOfPersonWhoPosted": "http://example.com/photo.jpg",
"nameOfPersonWhoPosted": "Jane Doe",
"message": "Sounds cool. Can't wait to see it!",
"likesCount": "2",
"comments": [],
"timeOfPost": "1234567890"
}
]
}
Java code :
JSONObject obj = new JSONObject(responsejsonobj);
String pageName = obj.getJSONObject("pageInfo").getString("pageName");
JSONArray arr = obj.getJSONArray("posts");
for (int i = 0; i < arr.length(); i++)
{
String post_id = arr.getJSONObject(i).getString("post_id");
......etc
}
Computer has revolutionized the world and programming is the most important tool to make our dream come true;
Showing posts with label json. Show all posts
Showing posts with label json. Show all posts
Saturday, April 9, 2016
java read json
Tuesday, April 14, 2015
ajax 读取json数据
click to gain json data
[
{"optionKey":"1", "optionValue":"Canon in D"},
{"optionKey":"2", "optionValue":"Wind Song"},
{"optionKey":"3", "optionValue":"Wings"}
]
Tuesday, April 7, 2015
jquery 解析 json数据
<script type="text/javascript">
$(document).ready(function(){
$("#button").click(function(){
alert ("good");
$.getJSON("http://localhost/index.php/users", function(json){
$.each(json, function(idx, obj) {
alert(obj.name);
});
});
});
});
</script>
json格式:
[{"user_id":"2","username":"guest2","name":"John","profile_pic":""},{"user_id":"1","username":"guest","name":"tom","profile_pic":""}]
json的格式对于解析非常重要,一定要规范化
$(document).ready(function(){
$("#button").click(function(){
alert ("good");
$.getJSON("http://localhost/index.php/users", function(json){
$.each(json, function(idx, obj) {
alert(obj.name);
});
});
});
});
</script>
json格式:
[{"user_id":"2","username":"guest2","name":"John","profile_pic":""},{"user_id":"1","username":"guest","name":"tom","profile_pic":""}]
json的格式对于解析非常重要,一定要规范化
Subscribe to:
Posts (Atom)