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


Java JSONObject.get方法代码示例

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


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

示例1: extractFormName

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private static String extractFormName(RpcResult result) {
  String extraString = result.getExtra();
  if (extraString != null) {
    JSONValue extraJSONValue = JSONParser.parseStrict(extraString);
    JSONObject extraJSONObject = extraJSONValue.isObject();
    if (extraJSONObject != null) {
      JSONValue formNameJSONValue = extraJSONObject.get("formName");
      if (formNameJSONValue != null) {
        JSONString formNameJSONString = formNameJSONValue.isString();
        if (formNameJSONString != null) {
          return formNameJSONString.stringValue();
        }
      }
    }
  }
  return "Screen1";
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:18,代码来源:WaitForBuildResultCommand.java

示例2: setOption

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private void setOption(JSONObject rootObject, String path, Object value) {
  if (path == null) {
    return;
  }
  if (path.startsWith("/")) {
    path = path.substring(1);
  }
  if (path.length() <= 0) {
    return;
  }
  String nodeName = path;
  if (nodeName.contains("/")) {
    nodeName = nodeName.substring(0, nodeName.indexOf("/"));
    JSONValue objectAsValue = rootObject.get(nodeName);
    if (objectAsValue == null || objectAsValue.isObject() == null) {
      rootObject.put(nodeName, new JSONObject());
    }
    JSONObject object = (JSONObject) rootObject.get(nodeName);
    setOption(object, path.substring(path.indexOf("/") + 1), value);
  } else {
    rootObject.put(nodeName, convertToJSONValue(value));
  }
}
 
开发者ID:jiakuan,项目名称:gwt-uploader,代码行数:24,代码来源:Configurable.java

示例3: parseDefaultValues

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
/**
 * Extracts default preference values from the gadget metadata JSON object
 * returned from GGS.
 *
 * @param prefs the preference JSON object received from GGS.
 */
public void parseDefaultValues(JSONObject prefs) {
  if (prefs != null) {
    for (String pref : prefs.keySet()) {
      if (!has(pref)) {
        JSONObject prefJson = prefs.get(pref).isObject();
        if (prefJson != null) {
          JSONValue value = prefJson.get("default");
          if ((value != null) && (value.isString() != null)) {
            put(pref, value.isString().stringValue());
            log("Gadget pref '" + pref + "' = '" + get(pref) + "'");
          }
        } else {
          log("Invalid pref '" + pref + "' value in Gadget metadata.");
        }
      }
    }
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:25,代码来源:GadgetUserPrefs.java

示例4: updateVariables

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private void updateVariables(JSONValue updatedVariablesJsonValue) {
    JSONObject obj = updatedVariablesJsonValue.isObject();
    if (obj != null) {
        for (String varName : obj.keySet()) {
            JobVariable variable = variables.get(varName);
            if (variable != null) {
                JSONValue variableJsonValue = obj.get(varName);
                JSONString variableJsonString = variableJsonValue.isString();
                if (variableJsonString != null) {
                    variable.setValue(variableJsonString.stringValue());
                }

            }
        }
    }
}
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:17,代码来源:SubmitWindow.java

示例5: onJsonReceived

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public void onJsonReceived(JSONValue jsonValue) {
	JSONObject jsonObject = jsonValue.isObject();
	if (jsonObject == null) {
		return;
	}
	if (jsonObject.containsKey("resumptionToken")) {
		resumptionToken = jsonObject.get("resumptionToken").isString().stringValue();
		nextCall();
	} else {
		if (jsonObject.containsKey("serverTime"))
			dataSourceModel.setServerTime((long) jsonObject.get("serverTime").isNumber().doubleValue());
	}
	if (jsonObject.get("error") != null) {
		Authentication.getInstance().disAuthenticate();
	} else {
		onJsonArrayReceived(jsonObject);
	}
}
 
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:19,代码来源:JsonResumptionListCallback.java

示例6: parseScriptResult

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private String parseScriptResult(String json) {
    StringBuilder scriptResultStr = new StringBuilder();
    JSONObject scriptResult = this.parseJSON(json).isObject();

    JSONObject exception = scriptResult.get("exception").isObject();
    while (exception != null && exception.get("cause") != null && exception.get("cause").isObject() != null) {
        exception = exception.get("cause").isObject();
    }

    if (exception != null && exception.get("message").isString() != null) {
        scriptResultStr.append(exception.get("message").isString().stringValue());
    }

    JSONString output = scriptResult.get("output").isString();
    if (output != null) {
        scriptResultStr.append(output.stringValue());
    }

    return scriptResultStr.toString();
}
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:21,代码来源:RMController.java

示例7: toMap

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public static Map<String, String> toMap(String jsonStr) {
  Map<String, String> map = new HashMap<String, String>();

  JSONValue parsed = JSONParser.parseStrict(jsonStr);
  JSONObject jsonObj = parsed.isObject();
  if (jsonObj != null) {
    for (String key : jsonObj.keySet()) {
      JSONValue jsonValue = jsonObj.get(key);
      JSONString jsonString = jsonValue.isString();
      // if the json value is a string, set the unescaped value, else set the json representation
      // of the value
      String stringValue = (jsonString == null) ? jsonValue.toString() : jsonString.stringValue();
      map.put(key, stringValue);
    }
  }

  return map;
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:JsonHelper.java

示例8: parseMap

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public static Map<String, String> parseMap(JSONValue jsonValue) {
	JSONObject obj = jsonValue.isObject();
	Map<String, String> map = new TreeMap<String, String>();
	
	if (obj != null) {
	
		for (String key : obj.keySet()) {
			JSONValue value = obj.get(key);

			if (value != null) {
				JSONString str = value.isString();
				
				if (str != null) {
					map.put(key, str.stringValue());
				}
			}
		}
	}
	
	return map;
}
 
开发者ID:dawg6,项目名称:dhcalc,代码行数:22,代码来源:JsonUtil.java

示例9: showResults

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public void showResults(JsonRiskAnalysis summary, JSONObject response) {
	risksLabel = new Label("Risks");
	risksLabel.setStyleName("smallTitle");
	goalsLabel = new Label("Goals");
	goalsLabel.setStyleName("smallTitle");
	
	this.response = response;
	this.summary = summary;
	this.jsonArgumentation = response.get("argumentation");
	Codec codec = GWT.create( Codec.class );
	
	if( jsonArgumentation != null ) {
		argumentation = codec.decode( jsonArgumentation );
	}
	results = new HashMap<>();
	
	tree.clear();
	if (response.get("hresults") != null ) generateTree(tree, response.get("hresults"));
	else {
		leftPanel.setWidth("0px");
		results.put(summary.getTarget(), response.get("results").isArray());
	}
	
	setSelectedEntity(summary.getTarget());
}
 
开发者ID:RISCOSS,项目名称:riscoss-corporate,代码行数:26,代码来源:RiskAnalysisResults.java

示例10: setStateOnModule

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private void setStateOnModule(JSONObject stateObj, IModule module) {
    if (moduleIsStatefulAndUnique(module)) {
        String moduleIdentifier = ((IUniqueModule) module).getIdentifier();

        if (identifierExistsInState(moduleIdentifier, stateObj)) {

            JSONValue moduleState = stateObj.get(moduleIdentifier);

            if (moduleStateExists(moduleState)) {
                ((Stateful) module).setState(moduleState.isArray());
            }
        }
    }
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:15,代码来源:ModulesStateLoader.java

示例11: testShouldWrapStateInJSONArray

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public void testShouldWrapStateInJSONArray() {
    // given
    String expectedKey = "test";
    double expectedNumberValue = 15.0;
    JSONObject givenObject = new JSONObject();
    givenObject.put(expectedKey, new JSONNumber(expectedNumberValue));

    JavaScriptObject jsObject = givenObject.getJavaScriptObject();
    int expectedArraySize = 1;

    // when
    JSONArray jsonArray = testObj.encodeState(jsObject);

    // then
    assertEquals(expectedArraySize, jsonArray.size());
    JavaScriptObject jsObjectResult = jsonArray.get(0).isObject().getJavaScriptObject();

    JSONObject jsonObjectResult = new JSONObject(jsObjectResult);

    assertEquals(jsonObjectResult.keySet().size(), 1);
    assertTrue(jsonObjectResult.containsKey(expectedKey));

    JSONValue valueResult = jsonObjectResult.get(expectedKey);
    assertNotNull(valueResult.isNumber());

    assertEquals(valueResult.isNumber().doubleValue(), expectedNumberValue);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:28,代码来源:ExternalStateEncoderGWTTestCase.java

示例12: onSuccess

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
@Override
        public void onSuccess(String json) {
            /*
             

{
  "table": {
    "columnNames": ["expocode", "vessel_name", "investigators", "qc_flag"],
    "columnTypes": ["String", "String", "String", "String"],
    "columnUnits": [null, null, null, null],
    "rows": [
      ["01AA20110928", "Nuka Arctica", "Truls Johannessen ; Abdirahman Omar ; Ingunn Skjelvan", "N"]
    ]
  }
}             
             
             
             */
            JSONValue jsonV = JSONParser.parseStrict(json);
            JSONObject jsonO = jsonV.isObject();
            if ( jsonO != null) {
                JSONObject table = (JSONObject) jsonO.get("table");
                JSONArray names = (JSONArray) table.get("columnNames");
                JSONArray rows = (JSONArray) table.get("rows");
                JSONArray r0 = (JSONArray) rows.get(0);
                for (int i = 0; i < names.size(); i++) {
                    
                    String name = names.get(i).toString();
                    if  ( name.endsWith("") ) name = name.substring(0,name.length()-1);
                    if  ( name.startsWith("") ) name = name.substring(1,name.length());

                    String value = r0.get(i).toString();
                    if  ( value.endsWith("") ) value = value.substring(0,value.length()-1);
                    if  ( value.startsWith("") ) value = value.substring(1,value.length());
                    
                    metadata.put(name.toUpperCase(Locale.ENGLISH), value);
                }
            }
            showMetadata();
        }
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:41,代码来源:ThumbnailPropProp.java

示例13: onSuccess

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
@Override
public void onSuccess(String json) {

	JSONValue jsonV = JSONParser.parseStrict(json);
	JSONObject jsonO = jsonV.isObject();
	MarkerClustererOptions clusterOptions = MarkerClustererOptions.newInstance();
	clusterOptions.setIgnoreHidden(true);
	MarkerClusterer cluster = MarkerClusterer.newInstance(mapUI.getMap(), clusterOptions);
	List<LatLng> locations = new ArrayList<LatLng>();
	if ( jsonO != null) {
		JSONObject table = (JSONObject) jsonO.get("table");
		JSONValue id = (JSONValue) table.get("catid");
		String catid = id.toString().trim().replace("\"", "");
		JSONArray names = (JSONArray) table.get("columnNames");
		JSONArray rows = (JSONArray) table.get("rows");

		int index = 0;
		for(int i = 1; i < rows.size(); i++) {
			JSONArray row = (JSONArray) rows.get(i);
			String latitude = row.get(0).toString();
			String longitude = row.get(1).toString();
			if ( latitude != null && longitude != null & !latitude.equals("null") && !longitude.equals("null")) {
				LatLng p = LatLng.newInstance(Double.valueOf(latitude), Double.valueOf(longitude));
				MarkerOptions options = MarkerOptions.newInstance();
				options.setPosition(p);
				options.setMap(mapUI.getMap());
				Marker marker = Marker.newInstance(options);
				locations.add(p);
				cluster.addMarker(marker);
			}
			index++;
		}

		mapUI.addMarkerClustererToPanel(catid, cluster);
		mapUI.addLocationsToPanel(catid, locations);
	}
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:38,代码来源:Inventory.java

示例14: getProperty

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private static JSONValue getProperty(JSONObject obj, String propertyName) throws JSONException {
    JSONValue jsonValue = obj.get(propertyName);
    if (jsonValue == null) {
        throw new JSONException("Expected JSON Object with attribute " + propertyName + ": " + obj.toString());
    }
    return jsonValue;
}
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:8,代码来源:SchedulerJSONUtils.java

示例15: getLongValue

import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private static long getLongValue(JSONObject obj, String fieldName) throws JSONException {
    JSONValue jsonLongValue = obj.get(fieldName);
    if (jsonLongValue == null) {
        throw new JSONException("Expected JSON Object with attribute " + fieldName + ": " + obj.toString());
    }
    JSONNumber jsonLong = jsonLongValue.isNumber();
    if (jsonLong == null) {
        throw new JSONException("Expected JSON number: " + jsonLongValue.toString());
    }
    return (long) jsonLong.doubleValue();
}
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:12,代码来源:SchedulerJSONUtils.java


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