本文整理汇总了Java中com.google.gwt.json.client.JSONString类的典型用法代码示例。如果您正苦于以下问题:Java JSONString类的具体用法?Java JSONString怎么用?Java JSONString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JSONString类属于com.google.gwt.json.client包,在下文中一共展示了JSONString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toJSON
import com.google.gwt.json.client.JSONString; //导入依赖的package包/类
@Override
public JSONValue toJSON() {
JSONArray jsonArr = new JSONArray();
jsonArr.set(0, new JSONString(OUTCOME));
jsonArr.set(1, new JSONString(identifier));
jsonArr.set(2, new JSONString(cardinality.toString()));
jsonArr.set(3, new JSONString(""));
JSONArray valuesArr = new JSONArray();
for (int v = 0; v < values.size(); v++) {
valuesArr.set(v, new JSONString(values.get(v)));
}
jsonArr.set(4, valuesArr);
jsonArr.set(5, new JSONString(interpretation));
jsonArr.set(6, new JSONNumber(normalMaximum));
return jsonArr;
}
示例2: testShouldReturnIdentifierFromState
import com.google.gwt.json.client.JSONString; //导入依赖的package包/类
public void testShouldReturnIdentifierFromState() throws Exception {
// given
String givenState = "givenState";
String identifier = "identifier";
JSONObject givenStateObject = new JSONObject();
givenStateObject.put(EmpiriaState.STATE, new JSONString(givenState));
givenStateObject.put(EmpiriaState.LESSON_IDENTIFIER, new JSONString(identifier));
givenStateObject.put(EmpiriaState.TYPE, new JSONString("LZ_GWT"));
// when
EmpiriaState result = testObj.deserialize(givenStateObject);
// then
assertEquals(result.getState(), givenState);
assertEquals(result.getLessonIdentifier(), identifier);
}
示例3: toList
import com.google.gwt.json.client.JSONString; //导入依赖的package包/类
public List<String> toList(String jsonStr) {
JSONValue parsed = JSONParser.parseStrict(jsonStr);
JSONArray jsonArray = parsed.isArray();
if (jsonArray == null) {
return Collections.emptyList();
}
List<String> list = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) {
JSONValue jsonValue = jsonArray.get(i);
JSONString jsonString = jsonValue.isString();
String stringValue = (jsonString == null) ? jsonValue.toString() : jsonString.stringValue();
list.add(stringValue);
}
return list;
}
示例4: toJSON
import com.google.gwt.json.client.JSONString; //导入依赖的package包/类
public String toJSON() {
JSONObject projectObject = new JSONObject();
projectObject.put("version", new JSONString(getVersion()));
projectObject.put("title", new JSONString(getTitle()));
projectObject.put("description", new JSONString(getDescription()));
projectObject.put("date", new JSONString(getDate()));
JSONArray layersArray = new JSONArray();
int index = 0;
for(ProjectVectorLayer projectLayer: vectors) {
layersArray.set(index, projectLayer.getJSONObject());
index++;
}
projectObject.put("vectors", layersArray);
return projectObject.toString();
}
示例5: extractFormName
import com.google.gwt.json.client.JSONString; //导入依赖的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";
}
示例6: applyAlphaMapMaterial
import com.google.gwt.json.client.JSONString; //导入依赖的package包/类
public void applyAlphaMapMaterial(Primitive primitive) {
JSONObject uniforms = new JSONObject();
uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
uniforms.put("channel", new JSONString("r"));
JSONObject alphaMaterial = new JSONObject();
alphaMaterial.put("type", new JSONString("AlphaMap"));
alphaMaterial.put("uniforms", uniforms);
JSONObject materials = new JSONObject();
materials.put("alphaMaterial", alphaMaterial);
JSONObject components = new JSONObject();
components.put("diffuse", new JSONString("vec3(1.0)"));
components.put("alpha", new JSONString("alphaMaterial.alpha"));
JSONObject fabric = new JSONObject();
fabric.put("materials", materials);
fabric.put("components", components);
MaterialOptions materialOptions = new MaterialOptions();
materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
primitive.appearance.material = new Material(materialOptions);
}
示例7: applyWaterMaterial
import com.google.gwt.json.client.JSONString; //导入依赖的package包/类
public void applyWaterMaterial(Primitive primitive) {
JSONObject uniforms = new JSONObject();
uniforms.put("specularMap", new JSONString(GWT.getModuleBaseURL() + "images/earthspec1k.jpg"));
uniforms.put("normalMap", new JSONString(GWT.getModuleBaseURL() + "images/waterNormals.jpg"));
uniforms.put("frequency", new JSONNumber(10000.0));
uniforms.put("animationSpeed", new JSONNumber(0.01));
uniforms.put("amplitude", new JSONNumber(1.0));
JSONObject fabric = new JSONObject();
fabric.put("type", new JSONString("Water"));
fabric.put("uniforms", uniforms);
MaterialOptions materialOptions = new MaterialOptions();
materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
primitive.appearance.material = new Material(materialOptions);
}
示例8: addOption
import com.google.gwt.json.client.JSONString; //导入依赖的package包/类
/**
* Add an option dynamically into the set of options that will be used by the init function
* for TinyMCE.
*
* @param key a string value denoting the configuration parameter (see TinyMCE documentation)
* @param value a value of Boolean, Integer, or String types.
*/
public void addOption(String key, Object value)
{
// do not allow overriding fixed options
if (fixedOptions.contains(key)) {
return;
}
if (value instanceof Boolean) {
options.put(key, JSONBoolean.getInstance((Boolean) value));
} else if (value instanceof Integer) {
options.put(key, new JSONNumber((Integer) value));
} else if (value instanceof String) {
options.put(key, new JSONString((String) value));
} else {
// Shouldn't ever really get to this, but just in case.
options.put(key, new JSONString(value.toString()));
}
}
示例9: getJsonObject
import com.google.gwt.json.client.JSONString; //导入依赖的package包/类
@Override
public String getJsonObject() {
JSONObject config=new JSONObject();
if(outputTables!=null) {
config.put("outputTables", new JSONString(outputTables));
}
if(syncTables!=null) {
config.put("syncTables", new JSONString(syncTables));
}
if(keepDays!=null) {
config.put("keepDays", new JSONString(keepDays.toString()));
}
if(driftPercent!=null) {
config.put("driftPercent", new JSONString(driftPercent.toString()));
}
JSONObject o=new JSONObject();
o.put("id", new JSONString(HiveP.ID));
o.put("config", config);
return o.toString();
}
示例10: helloWorld
import com.google.gwt.json.client.JSONString; //导入依赖的package包/类
private void helloWorld() throws Exception {
JSONObject sampleData = new JSONObject();
sampleData.put("Field1", new JSONNumber(1.0));
sampleData.put("Field2", new JSONString("Hello world"));
sampleData.put("Field3", JSONBoolean.getInstance(true));
// Sample 1 - basic usage
final FormLayout formLayout = new FormLayout(sampleData.toString());
RootPanel.get().add(formLayout);
Button button = new Button("Apply");
button.addStyleName(style.apply());
button.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Window.alert(formLayout.getDataJson());
}
});
formLayout.appendWidgetToBottom(button);
}
示例11: updateVariables
import com.google.gwt.json.client.JSONString; //导入依赖的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());
}
}
}
}
}
示例12: parseScriptResult
import com.google.gwt.json.client.JSONString; //导入依赖的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();
}
示例13: toMap
import com.google.gwt.json.client.JSONString; //导入依赖的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;
}
示例14: convertToJson
import com.google.gwt.json.client.JSONString; //导入依赖的package包/类
public static JSONValue convertToJson(Object value) {
if (value instanceof Enum) {
return new JSONString(((Enum<?>) value).name());
} else if (value instanceof String) {
return new JSONString((String) value);
} else if (value instanceof Number) {
return new JSONNumber(((Number) value).doubleValue());
} else if (value instanceof Boolean) {
return JSONBoolean.getInstance((boolean) value);
} else if (value instanceof JsonSerializable) {
return ((JsonSerializable) value).toJsonElement();
} else if (value instanceof JSONValue) {
return (JSONValue) value;
}
throw new RuntimeException("Unexpected runtime value: " + value);
}
示例15: uploadFile
import com.google.gwt.json.client.JSONString; //导入依赖的package包/类
private void uploadFile() {
JSONObject post = new JSONObject();
String mime = form.getValueAsString(FIELD_MIMETYPE);
if (mime != null && !mime.trim().isEmpty()) {
post.put(FIELD_MIMETYPE, new JSONString(mime));
}
post.put(FIELD_PID, new JSONString(dobj.getPid()));
String batchId = dobj.getBatchId();
if (batchId != null) {
post.put(FIELD_BATCHID, new JSONString(batchId));
}
post.put(DigitalObjectResourceApi.DISSEMINATION_ERROR, JSONBoolean.getInstance(true));
uploader.setPostParams(post);
uploader.startUpload();
showUploading(true);
}