java - 如何在java play框架1.2.x中解析来自php web服务的序列化json

标签 java json playframework jsonserializer

我需要使用来自php Web服务的一些内容,该服务通过java play框架1.2.x中的序列化json渲染其数据。我正在做的只是使用 play WS 功能。我正在从该服务获取数据。但是当我尝试使用 JSONObject 获取它时,它会抛出异常,这很正常,因为返回的数据看起来不太好。任何知道任何解决方法或解决方案的机构将不胜感激。

HttpResponse htp = WS.url("http://www.geoplugin.net/php.gp?ip=78.171.90.49").get();            
System.out.println(htp.getContentType()+"\n"+htp.getStatusText()+"\n"+htp.getString());

返回的数据:

a:18:{s:17:"geoplugin_request";s:12:"78.171.90.49";s:16:"geoplugin_status";i:200;s:16:"geoplugin_credit";s:145:"Some of the returned data includes GeoLite data created by MaxMind, available from <a href=\'http://www.maxmind.com\'>http://www.maxmind.com</a>.";s:14:"geoplugin_city";s:8:"Istanbul";s:16:"geoplugin_region";s:8:"Istanbul";s:18:"geoplugin_areaCode";s:1:"0";s:17:"geoplugin_dmaCode";s:1:"0";s:21:"geoplugin_countryCode";s:2:"TR";s:21:"geoplugin_countryName";s:6:"Turkey";s:23:"geoplugin_continentCode";s:2:"EU";s:18:"geoplugin_latitude";s:7:"41.0186";s:19:"geoplugin_longitude";s:9:"28.964701";s:20:"geoplugin_regionCode";s:2:"34";s:20:"geoplugin_regionName";s:8:"Istanbul";s:22:"geoplugin_currencyCode";s:3:"TRY";s:24:"geoplugin_currencySymbol";s:15:"&#89;&#84;&#76;";s:29:"geoplugin_currencySymbol_UTF8";s:3:"YTL";s:27:"geoplugin_currencyConverter";s:6:"2.2669";}

最佳答案

您正在访问 PHP 端点。您需要改为点击此网址:

http://www.geoplugin.net/json.gp?ip=78.171.90.49

关于java - 如何在java play框架1.2.x中解析来自php web服务的序列化json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21488545/

相关文章:

java - Google App Engine - 使用 Objectify 在本地连接到远程数据存储

javascript - 指定带引号和不带引号的 json key 之间有什么区别吗?

mysql - DB连接池过期了怎么办?

logging - 玩!框架日志记录功能

java - LinkedHashMap 的内部实现与 HashMap 实现有何不同?

java - 在 mysql 中检查用户名...如果存在则插入到其他表中否则基表

Scala 中的 Java 迭代器

java - org.springframework.http.converter.HttpMessageNotReadableException 调用休息后调用时

asp.net - 在 ASP.NET 网络表单中处理 JSON 响应

testing - 如何在 playframework 中测试 Jobs?