2013年10月31日星期四

JSON string parsing

Following this json string. I how to resolve ah. . .
request code. . I always parse out or parse error . . .
parsed into objects directly , not parsed into JSONObject object. . .


{"id": 259, "displayImageUrl": "http: \ / \ / res2.aduu.cn \ / union \ / img \ / 201308 \ / 16110341_G4uN.gif", "description" : "1234156", "name": " professional, honest, efficient, convenient, students preferred brand : King Gillette ! "," packagename ":" com.zhuamob "," TrackingUrl ": {" showUrl ": [" http: \ / \ / api.adcome.cn \ / v1 \ / evt? sourceid = zhuamao & ; appid = debugdis01 & uuid = 862873023463216ec: 17:2 f: 9d: 5d: 3400000 & reqid = 4wqq345txtdldr4o & nettype = 1 & adid = 259 & appver = 1.0 & sdkver = 1.0 & evttype = 1 "]," clickUrl " ;: ["http: \ / \ / api.adcome.cn \ / v1 \ / evt? sourceid = zhuamao & appid = debugdis01 & uuid = 862873023463216ec: 17:2 f: 9d: 5d: 3400000 & reqid = 4wqq345txtdldr4o & nettype = 1 & adid = 259 & appver = 1.0 & sdkver = 1.0 & evttype = 2 "," http: \ / \ / proxy-beta.zhuamob.com? data =% 7B% 22status% 22% 3A% 224 % 22% 2C% 22web% 22% 3A% 7B% 22app_user_id% 22% 3A213701% 2C% 22app_id% 22% 3A1767% 2C% 22ad_id% 22% 3A100003% 2C% 22ad_user_id% 22% 3A100003% 2C% 22price% 22% 3A10 % 2C% 22ad_type% 22% 3A4% 2C% 22imei% 22% 3A% 22862873023463216% 22% 2C% 22mac% 22% 3A% 22ec% 3A17% 3A2f% 3A9d% 3A5d% 3A34% 22% 2C% 22url% 22% 3A % 22% 22% 2C% 22show_type% 22% 3A% 221% 22% 7D% 7D & t = d8b217068cbc5de0795bd8c3fbf "]," installUrl ": [" http: \ / \ / api.adcome.cn \ / v1 \ / evt? sourceid = zhuamao & appid = debugdis01 & uuid = 862873023463216ec: 17:2 f: 9d: 5d: 3400000 & reqid = 4wqq345txtdldr4o & nettype = 1 & adid = 259 & appver = 1.0 & sdkver = 1.0 & evttype = 3 " ;]}, "actionType": "2", "type": "4", "actionUrl": "http: \ / \ / 121.199.2.166:8080 \ / ad \ / adwap \ / 0701a \ / index.jsp? sno = zhuamao & media_id = debugdis01 & adId = 259 "}
------ Solution -------------------- ------------------------
you parse out the object is not JsonObject?
instead of an actual object ?
{"id": 259,. . . }
In fact, this should also have an outside object to contain , where it is called ad
like this post I've seen a similar .

If you want to create an ad in the form of objects , then we need to build a kind of ad , ad type below contains id, http , and so forth .
like TrackingUrl like this, then this is an object , then you need to create a TrackingUrl this object class , which contains the same information and so on. . .
to a similar analytical methods it:
http://bbs.csdn.net/topics/390337723
------ Solution ----------------------- ---------------------
no jar. Js test with no problem .
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script>
$(document).ready(function(){
var t={
    "id": 259,
    "displayImageUrl": "http:\/\/res2.aduu.cn\/union\/img\/201308\/16110341_G4uN.gif",
    "description": "1234156",
    "name": "专业、诚信、高效、便捷,留学首选品牌:金吉列!",
    "packagename": "com.zhuamob",
    "TrackingUrl": {
        "showUrl": ["http:\/\/api.adcome.cn\/v1\/evt?

sourceid=zhuamao&appid=debugdis01&uuid=862873023463216ec:17:2f:9d:5d:3400000&reqid=4wqq345txtdldr4o&nettype=1&adid=259

&appver=1.0&sdkver=1.0&evttype=1"],
        "clickUrl": ["http:\/\/api.adcome.cn\/v1\/evt?

sourceid=zhuamao&appid=debugdis01&uuid=862873023463216ec:17:2f:9d:5d:3400000&reqid=4wqq345txtdldr4o&nettype=1&adid=259

&appver=1.0&sdkver=1.0&evttype=2", "http:\/\/proxy-beta.zhuamob.com?data=%7B%22status%22%3A%224%22%2C%22web%22%3A%7B%

22app_user_id%22%3A213701%2C%22app_id%22%3A1767%2C%22ad_id%22%3A100003%2C%22ad_user_id%22%3A100003%2C%22price%22%

3A10%2C%22ad_type%22%3A4%2C%22imei%22%3A%22862873023463216%22%2C%22mac%22%3A%22ec%3A17%3A2f%3A9d%3A5d%3A34%22%2C%

22url%22%3A%22%22%2C%22show_type%22%3A%221%22%7D%7D&t=d8b217068cbc5de0795bd8c3fbf"],
        "installUrl": ["http:\/\/api.adcome.cn\/v1\/evt?

sourceid=zhuamao&appid=debugdis01&uuid=862873023463216ec:17:2f:9d:5d:3400000&reqid=4wqq345txtdldr4o&nettype=1&adid=259

&appver=1.0&sdkver=1.0&evttype=3"]
    },
    "actionType": "2",
    "type": "4",
    "actionUrl": "http:\/\/121.199.2.166:8080\/ad\/adwap\/0701a\/index.jsp?sno=zhuamao&media_id=debugdis01&adId=259"
};
var subObj=t.TrackingUrl;
for (var i in subObj){
alert(i+"-->"+subObj[i]);
}
for (var i in t){
alert(i+"-->"+t[i]);
}
  
});
</script>
</head>
<body>

</body>
</html>

------ For reference only ----------------------------------- ----
there are many open source tools you can use ah

Gson pretty good , you go to google it , it will try to follow the examples used
------ For reference only ---------- -----------------------------

I use jsonObject
parse out is not my object
------ For reference only -------------------------- -------------
how you resolved ? Code does
------ For reference only -------------------------------- -------
you ask is what resolution ?

If js said they would not , would not want to get . . .


If it is pure java, can be considered to you I used to write packet
------ For reference only ------------------- --------------------




is that having JSONObject package . .
instead of js

------ For reference only ---------------------------------- -----

Why did not create many objects ?
------ For reference only -------------------------------------- -

Why did not create many objects ?  
no object What can you store these data

没有评论:

发表评论