小编Vip*_*opy的帖子

从 Java 中的 HTTP 响应解析 JSON

嗨,我正在使用客户端 Http (apache) 和 json-simple。

我想访问json响应的属性,然后使用它们。

知道如何做到这一点吗?我读了一篇文章,但我并没有像它那样工作。

这是我的回答 json:

{"Name":"myname","Lastname":"mylastname","Age":19}
Run Code Online (Sandbox Code Playgroud)

这是我的代码java:

DefaultHttpClient httpClient = new DefaultHttpClient();

HttpGet getRequest = new HttpGet(
    "http://localhost:8000/responsejava");
getRequest.addHeader("accept", "application/json");

HttpResponse response = httpClient.execute(getRequest);

if (response.getStatusLine().getStatusCode() != 200) {
    throw new RuntimeException("Failed : HTTP error code : "
             + response.getStatusLine().getStatusCode());
}

BufferedReader br = new BufferedReader(
    new InputStreamReader( 
        (response.getEntity().getContent())
    )
);

StringBuilder content = new StringBuilder();
String line;
while (null != (line = br.readLine())) {
    content.append(line);
}

Object obj=JSONValue.parse(content.toString());
JSONObject finalResult=(JSONObject)obj;
System.out.println(finalResult);

httpClient.getConnectionManager().shutdown();
Run Code Online (Sandbox Code Playgroud)

我打印了 null,我做错了什么?

java json http httpresponse json-simple

5
推荐指数
1
解决办法
3万
查看次数

如何在Angular 2中实现Chart.js?

我使用的是最新版本的Angular 2,V4.0.0,我想在我的项目中使用Chart.js库中的图形而没有太多复杂情况.

如何在我的角度项目中实现Chart.js,它不会在最终生产中给我带来问题?

html javascript typescript chart.js angular

5
推荐指数
3
解决办法
7344
查看次数

如何在Python中设置Gtk图像的大小

如何在Python 3中设置GTK图像宽度高度.

python gtk python-3.x gtk3

2
推荐指数
1
解决办法
1898
查看次数

如何在javafx中使用节点的宽度制作动画/过渡?

我想用节点的“宽度”制作动画。

在本例中,我的节点是“AnchorPane”。

我尝试在 javafx 中制作一个导航抽屉。

没有属性“width Property()”?

new Key Value (node.width Property (), 1, WEB_EASE)
Run Code Online (Sandbox Code Playgroud)

node.widthProperty().getValue() 未找到

我的代码:

public void changeWidth(final Node node, double width) {
    this.node = node;
    this.timeline = TimelineBuilder.create()
        .keyFrames(
            new KeyFrame(Duration.millis(20),    
                new KeyValue(    going here?   , width, WEB_EASE)
            )
        )
        .build();

    setCycleDuration(Duration.seconds(5));
    setDelay(Duration.seconds(0));
}
Run Code Online (Sandbox Code Playgroud)

“不透明度”属性的示例:

new KeyValue(node.opacityProperty(), 1, WEB_EASE)
Run Code Online (Sandbox Code Playgroud)

我的类 ConfigAnimationViewPane:

public class ConfigAnimationViewPane extends Transition {
    protected static final Interpolator WEB_EASE = Interpolator.EASE_BOTH;
    protected AnchorPane node;
    protected Timeline timeline;
    private boolean oldCache = false; …
Run Code Online (Sandbox Code Playgroud)

java animation transition javafx

1
推荐指数
1
解决办法
2937
查看次数