我有以下JSON文本.如何可以解析它来获得pageName,pagePic,post_id,等?
{
"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"
}
]
}
Run Code Online (Sandbox Code Playgroud) 我不太确定如何获取机器的外部IP地址,因为网络外的计算机会看到它.
我的以下IPAddress类仅获取计算机的本地IP地址.
public class IPAddress {
private InetAddress thisIp;
private String thisIpAddress;
private void setIpAdd() {
try {
InetAddress thisIp = InetAddress.getLocalHost();
thisIpAddress = thisIp.getHostAddress().toString();
} catch (Exception e) {
}
}
protected String getIpAddress() {
setIpAdd();
return thisIpAddress;
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用此方法获取远程IP:
String remoteAddress = ((ServletRequestAttributes) RequestContextHolder
.currentRequestAttributes()).getRequest().getRemoteAddr();
Run Code Online (Sandbox Code Playgroud)
我在控制器中调用它,但它返回0:0:0:0:0:0:0:1.怎么了?
我在android上有一个应用程序,我正在连接到一个网站获取一些数据.是否有可能找到我实际连接的IP地址?我正在做:
HttpUriRequest request = new HttpGet("http://www.example.com");
DefaultHttpClient client = new DefaultHttpClient(params);
HttpResponse response = client.execute(request);
println("You connected to: " + response.getIpAddress(?));
Run Code Online (Sandbox Code Playgroud)
谢谢
java ×4
android ×1
external ×1
ip ×1
ip-address ×1
json ×1
networking ×1
parsing ×1
servlets ×1
spring ×1