本文整理汇总了Java中com.google.gwt.json.client.JSONObject.toString方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.toString方法的具体用法?Java JSONObject.toString怎么用?Java JSONObject.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.json.client.JSONObject
的用法示例。
在下文中一共展示了JSONObject.toString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toJSON
import com.google.gwt.json.client.JSONObject; //导入方法依赖的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();
}
示例2: getJsonObject
import com.google.gwt.json.client.JSONObject; //导入方法依赖的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();
}
示例3: helloWorld
import com.google.gwt.json.client.JSONObject; //导入方法依赖的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);
}
示例4: generateDragComponentJSON
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public String generateDragComponentJSON(LayoutDragComponent dragComponent) {
JSONObject jsonComponent = new JSONObject();
extractBeanClass(dragComponent,
jsonComponent);
if (dragComponent instanceof HasDragAndDropSettings) {
JSONObject params = new JSONObject();
HasDragAndDropSettings sComponent = (HasDragAndDropSettings) dragComponent;
for (String key : sComponent.getSettingsKeys()) {
String value = sComponent.getSettingValue(key);
params.put(key,
new JSONString(value));
}
jsonComponent.put(COMPONENT_PARAMS,
params);
}
return jsonComponent.toString();
}
示例5: getDataJson
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public String getDataJson() {
JSONObject data = new JSONObject();
for (String key : fieldOrder) {
try {
FormField field = getField(key);
data.put(key, field.getJsonValue());
} catch (Exception e) {
ClientSideLogger.get().log(Level.WARNING, "exception: ", e);
}
}
return data.toString();
}
示例6: 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;
}
示例7: 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();
}
示例8: toJson
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
public static String toJson(Map<String, String> map) {
String json = "";
if (map != null && !map.isEmpty()) {
JSONObject jsonObj = new JSONObject();
for (Map.Entry<String, String> entry : map.entrySet()) {
jsonObj.put(entry.getKey(), new JSONString(entry.getValue()));
}
json = jsonObj.toString();
}
return json;
}
示例9: yamlPreferencesToJson
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
/**
* Convert YamlPreference's to JSON
*
* @param yamlPreferencesList
* @return String of yamlPreferences
*/
private String yamlPreferencesToJson(List<YamlPreference> yamlPreferencesList) {
Map<String, List<String>> schemaMap = PreferenceHelper.yamlPreferenceToMap(yamlPreferencesList);
JSONObject jsonObj = new JSONObject();
for (String glob : schemaMap.keySet()) {
jsonObj.put(glob, prefListToJsonArray(schemaMap.get(glob)));
}
return jsonObj.toString();
}
示例10: getToken
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
@Override
public String getToken(DigitalObjectCreatorPlace place) {
JSONObject json = new JSONObject();
JsonTokenizer.putString(json, MODEL, place.model);
JsonTokenizer.putString(json, PARENT, place.parent);
String jsonString = json.toString();
return jsonString;
}
示例11: getToken
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
@Override
public String getToken(ImportPlace place) {
JSONObject json = new JSONObject();
Type importType = place.getType();
JsonTokenizer.putString(json, TYPE, importType == null ? null : importType.name());
JsonTokenizer.putString(json, BATCHID, place.getBatchId());
return json.toString();
}
示例12: toToken
import com.google.gwt.json.client.JSONObject; //导入方法依赖的package包/类
@Override
public String toToken() {
JSONObject json = new JSONObject();
JsonTokenizer.putString(json, Tokenizer.TYPE, Type.JOBS.name());
return json.toString();
}