本文整理汇总了Java中com.google.gwt.json.client.JSONObject.getJavaScriptObject方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.getJavaScriptObject方法的具体用法?Java JSONObject.getJavaScriptObject怎么用?Java JSONObject.getJavaScriptObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.json.client.JSONObject
的用法示例。
在下文中一共展示了JSONObject.getJavaScriptObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getState
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
private JavaScriptObject getState(JSONValue jsonValue) {
JSONObject state = jsonValue.isObject();
if (state.containsKey(STATE)) {
return state.get(STATE).isArray().get(0).isObject().getJavaScriptObject();
}
return state.getJavaScriptObject();
}
示例2: getJSONObject
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public JavaScriptObject getJSONObject() {
JSONObject jsonEvent = new JSONObject();
String type = getEventType();
jsonEvent.put(EVENT_TYPE, new JSONString(type));
JavaScriptObject jsPayload = getPayload().getJavaScriptObject();
jsonEvent.put(EVENT_PAYLOAD, new JSONObject(jsPayload));
return jsonEvent.getJavaScriptObject();
}
示例3: 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);
}
示例4: dataToJSObject
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
/**
* Get a {@code JavaScriptObject} containing map information as
* required by the library.
*
* @param data {@code Map} of ISO codes and values.
* @return {@code JavaScriptObject} as required by the library.
*/
private JavaScriptObject dataToJSObject(Map<String, Double> data) {
if (data == null) {
return null;
}
JSONObject dataObject = new JSONObject();
for (Map.Entry<String, Double> entry : data.entrySet()) {
dataObject.put(entry.getKey(), new JSONNumber(entry.getValue()));
}
return dataObject.getJavaScriptObject();
}