当前位置: 首页>>代码示例>>Java>>正文


Java JSONArray.getDouble方法代码示例

本文整理汇总了Java中org.json.JSONArray.getDouble方法的典型用法代码示例。如果您正苦于以下问题:Java JSONArray.getDouble方法的具体用法?Java JSONArray.getDouble怎么用?Java JSONArray.getDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.json.JSONArray的用法示例。


在下文中一共展示了JSONArray.getDouble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getArrayDouble

import org.json.JSONArray; //导入方法依赖的package包/类
public static double[] getArrayDouble(JSONObject docObj, String name) {
	double[] list = null;
	if (docObj.has(name)) {
		JSONArray json;
		try {
			json = docObj.getJSONArray(name);
			int lenFeatures = json.length();
			list = new double[lenFeatures];
			for (int j = 0; j < lenFeatures; j++) {
				double f = json.getDouble(j);
				list[j] = f;
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}

	}
	return list;

}
 
开发者ID:NewCasino,项目名称:browser,代码行数:21,代码来源:JSONUtil.java

示例2: parseTrade

import org.json.JSONArray; //导入方法依赖的package包/类
/**
 * Parse message that contains one update - trade
 *
 * @param market
 * @param values
 * @return
 */
private ParserResponse parseTrade(Market market, JSONArray values) {
    try {
        int tradeId = values.getInt(0);
        long timestampMs = values.getLong(1);
        Decimal amount = new Decimal(values.getDouble(2));
        boolean sellSide;
        if (amount.isNegative()) {
            // Negative amount means "this was a sell-side trade"
            amount = amount.negate();
            sellSide = true;
        } else {
            sellSide = false;
        }
        Decimal price = new Decimal(values.getDouble(3));
        Date time = new Date(timestampMs);
        Trade trade = new Trade(time, price, amount, sellSide);
        market.addTrade(trade);

        return null;
    } catch (JSONException e) {
        Logger.log("Error while parsing JSON msg: " + values);
        return shutDownAction("Error in BitFinex update parsing:"
                + e.getMessage());
    }
}
 
开发者ID:prog-fun,项目名称:exchange-apis,代码行数:33,代码来源:BitFinexParser.java

示例3: marathon_select

import org.json.JSONArray; //导入方法依赖的package包/类
@Override public boolean marathon_select(String value) {
    SplitPane splitPane = (SplitPane) getComponent();
    JSONArray locations = new JSONArray(value);
    double[] dividerLocations = new double[locations.length()];
    for (int i = 0; i < locations.length(); i++) {
        dividerLocations[i] = locations.getDouble(i);
    }
    splitPane.setDividerPositions(dividerLocations);
    return true;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:11,代码来源:JavaFXSplitPaneElement.java

示例4: select

import org.json.JSONArray; //导入方法依赖的package包/类
@Test public void select() {
    SplitPane splitPaneNode = (SplitPane) getPrimaryStage().getScene().getRoot().lookup(".split-pane");
    JSONArray initialValue = new JSONArray(splitPaneNode.getDividerPositions());
    Platform.runLater(() -> {
        splitPane.marathon_select("[0.6]");
    });
    new Wait("Waiting for split pane to set divider location") {
        @Override public boolean until() {
            return initialValue.getDouble(0) != new JSONArray(splitPaneNode.getDividerPositions()).getDouble(0);
        }
    };
    JSONArray pa = new JSONArray(splitPaneNode.getDividerPositions());
    AssertJUnit.assertEquals(0.6, pa.getDouble(0), 0.2);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:15,代码来源:JavaFXSplitPaneElementTest.java

示例5: select2

import org.json.JSONArray; //导入方法依赖的package包/类
@Test public void select2() {
    SplitPane splitPaneNode = (SplitPane) getPrimaryStage().getScene().getRoot().lookup(".split-pane");
    JSONArray initialValue = new JSONArray(splitPaneNode.getDividerPositions());
    Platform.runLater(() -> {
        splitPane.marathon_select("[0.30158730158730157,0.8]");
    });
    new Wait("Waiting for split pane to set divider location") {
        @Override public boolean until() {
            return initialValue.getDouble(1) != new JSONArray(splitPaneNode.getDividerPositions()).getDouble(1);
        }
    };
    JSONArray pa = new JSONArray(splitPaneNode.getDividerPositions());
    AssertJUnit.assertEquals(0.8, pa.getDouble(1), 0.1);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:15,代码来源:JavaFXSplitPaneElementTest.java

示例6: readCoordinates

import org.json.JSONArray; //导入方法依赖的package包/类
private Coordinate[] readCoordinates(JSONArray value)
{
    int n = value.length();

    Coordinate[] coords = new Coordinate[n];

    for (int i = 0; i < n; i++)
    {
        JSONArray arrCoord = value.getJSONArray(i);
        coords[i] = new Coordinate(arrCoord.getDouble(0), arrCoord.getDouble(1));
    }

    return coords;
}
 
开发者ID:GIScience,项目名称:openrouteservice-tools,代码行数:15,代码来源:BorderPolygonTask.java

示例7: parseJsonFromDataSet

import org.json.JSONArray; //导入方法依赖的package包/类
static DataList parseJsonFromDataSet(JSONObject obj) throws IOException, JSONException, ParseException {
    DataList dataList = new DataList();
    // loop array
    JSONArray vel_raw = (JSONArray) obj.get("vel_raw");
    //Iterator<String> raw_iterator = vel_raw.length();
    int length = vel_raw.length();
    dataList.setVelRawLength(length);
   // float[] rawArray = new float[2048];
    float[] rawArray = new float[100];
    for(int i = 0 ; i < length ; i ++) {
        Log.d("DEBUG",vel_raw.getString(i));
        rawArray[i] = (float) vel_raw.getDouble(i);
    }
    dataList.setVelRaw(rawArray);
    dataList.setVelRawLength(length);

    double vel_max =(double) obj.get("vel_max");
    Log.d("DEBUG", String.valueOf(vel_max));
    dataList.setVelMax((float) vel_max);


    JSONArray dis_raw = (JSONArray) obj.get("dis_raw");
    //float[] disArray = new float[2048];
    float[] disArray = new float[100];
    int maxLength = dis_raw.length();
    dataList.setDisRawLength(maxLength);
    for(int i = 0 ; i < maxLength ; i ++) {
        Log.d("DEBUG", dis_raw.getString(i));
        disArray[i] = (float) vel_raw.getDouble(i);
    }
    dataList.setDisRaw(disArray);
    dataList.setDisRawLength(maxLength);

    double dis_max = obj.getDouble("dis_max");
    Log.d("DEBUG", String.valueOf(dis_max));
    dataList.setDisMax((float) dis_max);

    return dataList;
}
 
开发者ID:Ksj7,项目名称:Rabbitqueue,代码行数:40,代码来源:DataJSONParser.java

示例8: a

import org.json.JSONArray; //导入方法依赖的package包/类
static GroupData a(String paramString, JSONObject paramJSONObject)
        throws JSONException, IOException {
    GroupData locala = new GroupData();
    locala.name = paramJSONObject.getString("foldername");
    locala.cN = paramJSONObject.getInt("maxcount");
    locala.ee = paramJSONObject.getInt("resloadtype");
    locala.bS = paramJSONObject.getString("audio");
    locala.bQ = paramJSONObject.getInt("soundPlayMode");
    locala.di = paramJSONObject.getInt("triggerType");

    locala.cv = new ArrayList();
    JSONArray localJSONArray1 = paramJSONObject.getJSONArray("pointindexarray");
    for (int i = 0; i < localJSONArray1.length(); i++) {
        JSONArray localJSONArray3 = localJSONArray1.getJSONArray(i);
        for (int k = 0; k < localJSONArray3.length(); k++) {
            GroupData.b locala1 = new GroupData.b();
            locala1.cx = i;
            locala1.cy = localJSONArray3.getInt(k);
            locala.cv.add(locala1);
        }
    }
    locala.bO = new float[8];
    JSONArray localJSONArray2 = paramJSONObject.getJSONArray("timeparam");
    for (int j = 0; j < 8; j++) {
        locala.bO[j] = ((float) localJSONArray2.getDouble(j));
    }
    JSONArray localJSONArray4 = paramJSONObject.getJSONArray("reslist");
    locala.ed = new ArrayList();
    for (int k = 0; k < localJSONArray4.length(); k++) {
        locala.ed.add(localJSONArray4.getString(k));
    }
    File localFile = new File(paramString + "/" + locala.name, "glsl");
    locala.bN = IOUtils.convertStreamToString(new FileInputStream(localFile));
    return locala;
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:36,代码来源:FilterFactory.java

示例9: beatListFromResponse

import org.json.JSONArray; //导入方法依赖的package包/类
public static List<Double> beatListFromResponse(String response){
    List<Double> beatList = new ArrayList<Double>();
    try{
        JSONObject metadata = new JSONObject(response);
        JSONArray beats = metadata.getJSONObject("rhythm").getJSONArray("beats_position");
        for(int i = 0 ; i < beats.length();i++) {
            double tapAtTime = (beats.getDouble(i));
            beatList.add(tapAtTime);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return beatList;
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:15,代码来源:PanakoWebserviceClient.java

示例10: parseOrderUpdate

import org.json.JSONArray; //导入方法依赖的package包/类
/**
 * Parse message that contains one update to the orderbook
 *
 * @param market
 * @param values
 * @return
 */
private ParserResponse parseOrderUpdate(Market market, JSONArray values) {
    try {
        Decimal price = new Decimal(values.getDouble(0));
        int count = values.getInt(1);
        Decimal amount = new Decimal(values.getDouble(2));
        if (count > 0) {
            // BitFinex always reports the total updated amount, 
            // not the difference. Therefore we must set the final value, 
            // not increment
            if (amount.isPositive()) {
                market.addBid(price, amount, count, false);
            } else if (amount.isNegative()) {
                market.addAsk(price, amount.negate(), count, false);
            }
        } else if (count == 0) {
            if (amount.equals(Decimal.ONE)) {
                market.removeBid(price);
            } else if (amount.negate().equals(Decimal.ONE)) {
                market.removeAsk(price);
            }
        }

        return null;
    } catch (JSONException e) {
        Logger.log("Error while parsing JSON msg: " + values);
        return shutDownAction("Error in BitFinex update parsing:"
                + e.getMessage());
    }
}
 
开发者ID:prog-fun,项目名称:exchange-apis,代码行数:37,代码来源:BitFinexParser.java

示例11: onPostExecute

import org.json.JSONArray; //导入方法依赖的package包/类
protected void onPostExecute(String response) {
    double zebpaybuy = 0;
    double zebpaysell = 0;
    String bitf1 = null;
    String bitf2 = null;
    if (response == null) {
        response = "THERE WAS AN ERROR";
    }
    try {
        JSONArray array = (JSONArray)new JSONTokener(response).nextValue();
        zebpaybuy = array.getDouble(0);
        zebpaysell = array.getDouble(2);

        bitf1 = Double.toString(zebpaybuy);
        bitf2 = Double.toString(zebpaysell);
        System.out.println("Bid "+zebpaybuy+"ask"+zebpaysell);

    } catch (JSONException e) {
        // Appropriate error handling code
        Log.e("Erooor",e.getMessage(),e);
    }
    Log.i("INFO", response);
    textView1.setText(bitf1);
    textView2.setText(bitf2);
    min = Double.parseDouble(bitf1);
    System.out.println("The Minimum price is "+min);

    if (Double.parseDouble(bitf1)<=min)
    {
        flag =1;
    }

    max = Double.parseDouble(bitf2);
    System.out.println("The Minimum price is "+max);

    if (Double.parseDouble(bitf2)>=max)
    {
        flag1 =1;
    }

}
 
开发者ID:someaditya,项目名称:CoinPryc,代码行数:42,代码来源:ThirdActivity.java

示例12: readPoint

import org.json.JSONArray; //导入方法依赖的package包/类
private static Point readPoint(JSONArray value)
{
	Coordinate c = new Coordinate(value.getDouble(0), value.getDouble(1));
	return factory.createPoint(c);
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:6,代码来源:GeometryJSON.java

示例13: call

import org.json.JSONArray; //导入方法依赖的package包/类
public String call(WebView webView, JSONObject jsonObject) {
    long time = 0;
    if (LogUtils.isDebug()) {
        time = android.os.SystemClock.uptimeMillis();
    }
    if (jsonObject != null) {
        try {
            String methodName = jsonObject.getString(KEY_METHOD);
            JSONArray argsTypes = jsonObject.getJSONArray(KEY_TYPES);
            JSONArray argsVals = jsonObject.getJSONArray(KEY_ARGS);
            String sign = methodName;
            int len = argsTypes.length();
            Object[] values = new Object[len];
            int numIndex = 0;
            String currType;

            for (int k = 0; k < len; k++) {
                currType = argsTypes.optString(k);
                if ("string".equals(currType)) {
                    sign += "_S";
                    values[k] = argsVals.isNull(k) ? null : argsVals.getString(k);
                } else if ("number".equals(currType)) {
                    sign += "_N";
                    numIndex = numIndex * 10 + k + 1;
                } else if ("boolean".equals(currType)) {
                    sign += "_B";
                    values[k] = argsVals.getBoolean(k);
                } else if ("object".equals(currType)) {
                    sign += "_O";
                    values[k] = argsVals.isNull(k) ? null : argsVals.getJSONObject(k);
                } else if ("function".equals(currType)) {
                    sign += "_F";
                    values[k] = new JsCallback(webView, mInterfacedName, argsVals.getInt(k));
                } else {
                    sign += "_P";
                }
            }

            Method currMethod = mMethodsMap.get(sign);

            // 方法匹配失败
            if (currMethod == null) {
                return getReturn(jsonObject, 500, "not found method(" + sign + ") with valid parameters", time);
            }
            // 数字类型细分匹配
            if (numIndex > 0) {
                Class[] methodTypes = currMethod.getParameterTypes();
                int currIndex;
                Class currCls;
                while (numIndex > 0) {
                    currIndex = numIndex - numIndex / 10 * 10 - 1;
                    currCls = methodTypes[currIndex];
                    if (currCls == int.class) {
                        values[currIndex] = argsVals.getInt(currIndex);
                    } else if (currCls == long.class) {
                        //WARN: argsJson.getLong(k + defValue) will return a bigger incorrect number
                        values[currIndex] = Long.parseLong(argsVals.getString(currIndex));
                    } else {
                        values[currIndex] = argsVals.getDouble(currIndex);
                    }
                    numIndex /= 10;
                }
            }

            return getReturn(jsonObject, 200, currMethod.invoke(mInterfaceObj, values), time);
        } catch (Exception e) {
            LogUtils.safeCheckCrash(TAG, "call", e);
            //优先返回详细的错误信息
            if (e.getCause() != null) {
                return getReturn(jsonObject, 500, "method execute error:" + e.getCause().getMessage(), time);
            }
            return getReturn(jsonObject, 500, "method execute error:" + e.getMessage(), time);
        }
    } else {
        return getReturn(jsonObject, 500, "call data empty", time);
    }
}
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:78,代码来源:JsCallJava.java

示例14: readPoint

import org.json.JSONArray; //导入方法依赖的package包/类
private Point readPoint(JSONArray value)
{
    Coordinate c = new Coordinate(value.getDouble(0), value.getDouble(1));
    return factory.createPoint(c);
}
 
开发者ID:GIScience,项目名称:openrouteservice-tools,代码行数:6,代码来源:BorderTask.java

示例15: g

import org.json.JSONArray; //导入方法依赖的package包/类
static MultiTriangleInfo g(String paramString)
        throws JSONException {
    MultiTriangleInfo localMultiTriangleInfo = new MultiTriangleInfo();
    JSONObject localJSONObject1 = new JSONObject(paramString);
    localMultiTriangleInfo.eI = new ArrayList();
    localMultiTriangleInfo.bP = localJSONObject1.getString("tips");

    JSONArray localJSONArray1 = localJSONObject1.getJSONArray("itemlist");
    for (int i = 0; i < localJSONArray1.length(); i++) {
        MultiTriangleInfo.a locala = new MultiTriangleInfo.a();
        JSONObject localJSONObject2 = localJSONArray1.getJSONObject(i);

        locala.eq = localJSONObject2.getString("resname");
        JSONArray localJSONArray2 = localJSONObject2.getJSONArray("vertexidx");
        locala.eJ = new int[localJSONArray2.length()];
        for (int j = 0; j < localJSONArray2.length(); j++) {
            locala.eJ[j] = localJSONArray2.getInt(j);
        }
        JSONArray localJSONArray3 = localJSONObject2.getJSONArray("resFacePointsKey");
        locala.eN = new int[localJSONArray3.length()];
        for (int k = 0; k < localJSONArray3.length(); k++) {
            locala.eN[k] = localJSONArray3.getInt(k);
        }
        JSONArray localJSONArray4 = localJSONObject2.getJSONArray("resFacePointsValue");
        locala.eO = new PointF[localJSONArray4.length() / 2];
        for (int m = 0; m < locala.eO.length; m++) {
            locala.eO[m] = new PointF();
            locala.eO[m].x = ((float) localJSONArray4.getDouble(2 * m));
            locala.eO[m].y = ((float) localJSONArray4.getDouble(2 * m + 1));
        }
        JSONArray localJSONArray5 = localJSONObject2.getJSONArray("scaleIdx");
        locala.eK = new int[2];
        locala.eK[0] = localJSONArray5.getInt(0);
        locala.eK[1] = localJSONArray5.getInt(1);

        JSONArray localJSONArray6 = localJSONObject2.getJSONArray("baselineIdx");
        locala.eL = new int[localJSONArray6.length()];
        for (int n = 0; n < localJSONArray6.length(); n++) {
            locala.eL[n] = localJSONArray6.getInt(n);
        }
        JSONArray localJSONArray7 = localJSONObject2.getJSONArray("fakePosScaleRatio");
        locala.eM = new PointF[localJSONArray7.length() / 2];
        for (int i1 = 0; i1 < locala.eM.length; i1++) {
            locala.eM[i1] = new PointF();
            locala.eM[i1].x = ((float) localJSONArray7.getDouble(2 * i1));
            locala.eM[i1].y = ((float) localJSONArray7.getDouble(2 * i1 + 1));
        }
        localMultiTriangleInfo.eI.add(locala);
    }
    return localMultiTriangleInfo;
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:52,代码来源:FilterFactory.java


注:本文中的org.json.JSONArray.getDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。