gpt4 book ai didi

java - GSON 新手 : parse a JSON string into into a double[] ref

转载 作者:行者123 更新时间:2023-11-30 08:53:04 28 4
gpt4 key购买 nike

给定

 String theJSON = "{\"fundingRates\": ["+
"-0.00811024530204814,-0.00811024530204814,-0.00523639835476781,"
"-0.00556478090396538,0.00119056866828458,0.000230747044382269,"+
"-0.00445402087571539,-0.00424534913554488,-0.00600219416905775,"+
"-0.0117388075769262,-0.00887855826135051,-0.0072704827246495]} ";

我将如何编写 GSON 代码

将这些值放入

double[] fundingRates;

?

最佳答案

这应该适合你:

double[] fundingRates = new Gson().fromJson(new JsonParser().parse(theJson).getAsJsonObject().get("fundingRates"), double[].class);

关于java - GSON 新手 : parse a JSON string into into a double[] ref,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29927635/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com