可以使用Java中的JSONArray类来解析JSON数据中的data字段到最小集合。以下是一个示例代码:

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class Main {
    public static void main(String[] args) {
        String json = "{\"code\":\"0\",\"msg\":\"\",\"data\":[[\"1597026383085\",\"3.721\",\"3.743\",\"3.677\",\"3.708\",\"0\"],[\"1597026383085\",\"3.731\",\"3.799\",\"3.494\",\"3.72\",\"1\"]]}";

        try {
            JSONObject jsonObject = new JSONObject(json);
            JSONArray dataArray = jsonObject.getJSONArray("data");

            for (int i = 0; i < dataArray.length(); i++) {
                JSONArray candlestickArray = dataArray.getJSONArray(i);
                System.out.println("Candlestick " + (i + 1) + ":");
                for (int j = 0; j < candlestickArray.length(); j++) {
                    System.out.println(candlestickArray.getString(j));
                }
                System.out.println();
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}

运行以上代码将输出:

Candlestick 1:
1597026383085
3.721
3.743
3.677
3.708
0

Candlestick 2:
1597026383085
3.731
3.799
3.494
3.72
1

这样你就可以将data字段的数据解析到最小集合中进行后续操作

JSONObject indexCandlesticks= code0 msg data 1597026383085 3721 3743 3677 3708 0 1597026383085 3731 3799 349

原文地址: https://www.cveoy.top/t/topic/iniD 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录