php - Java: Parsing Json Correctly? -
php - Java: Parsing Json Correctly? -
i have array in json output:
print json_decode($array);
the string results in:
{"dbonline":true,"success":true,"action":"geturls","authorized":true, "urls":[ {"url":"http:\/\/www.namhost.com"}, {"url":"http:\/\/www.voomka.com"}, {"url":"http:\/\/www.ournamibia.com"}] }
note // part. how this:
header('content-type: application/json'); echo json_encode($result);
i utilize java grab url printed, , parse it:
private arraylist<string> extracturls(string jsontext) { arraylist<string> urlresults = new arraylist<string>(); jsonparserfactory mill = jsonparserfactory.getinstance(); jsonparser parser = factory.newjsonparser(); map jsondata = parser.parsejson(jsontext); arraylist urllist = (arraylist)jsondata.get("urls"); (object u : urllist) { hashmap hashmap = (hashmap)u; string url = hashmap.get("url").tostring(); urlresults.add(url); } homecoming urlresults; }
the problem is, array list beingness homecoming has values:
[0] = (string) "http:\\/\\/www.namhost.com\\/blog\\/2014-06-11\\/how-to-choose-right-software-solution"
in other words, json "slashing" hasn't been removed. don't want manually remove here, seems problem parsing directly.
any ideas how prepare this?
just seek code: there no need of escape sequence
{"dbonline":true,"success":true,"action":"geturls","authorized":true, "urls":[ {"url":"http://www.namhost.com"}, {"url":"http://www.voomka.com"}, {"url":"http://www.ournamibia.com"}] }
java php json
Comments
Post a Comment