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


Java JSONValue.toString方法代码示例

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


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

示例1: toList

import com.google.gwt.json.client.JSONValue; //导入方法依赖的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;
  }
 
开发者ID:eclipse,项目名称:che-archetypes,代码行数:20,代码来源:StringListUnmarshaller.java

示例2: getTagsFromJson

import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
/**
 * @param arr list of tags as a JSON array
 * @return the list of tags
 */
public static List<String> getTagsFromJson(String result) throws JSONException {
    JSONValue val = parseJSON(result);
    JSONArray arr = val.isArray();
    if (arr == null) {
        throw new JSONException("Expected JSON Array: " + val.toString());
    }

    List<String> tags = new ArrayList<String>(arr.size());

    for (int i = 0; i < arr.size(); i++) {
        tags.add(arr.get(i).isString().stringValue());
    }

    return tags;
}
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:20,代码来源:SchedulerJSONUtils.java

示例3: getJobsFromJson

import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
private static Map<Integer, Job> getJobsFromJson(JSONValue value, JobsPaginationModel paginationModel)
        throws JSONException {
    Map<Integer, Job> jobs = new HashMap<>();

    JSONObject jsonMain = getObject(value);

    JSONValue jsonError = jsonMain.get("errors");
    if (jsonError != null) {
        throw new JSONException(jsonError.toString());
    }

    JSONObject jsonData = getObject(getProperty(jsonMain, "data"));
    JSONObject jsonJobs = getObject(getProperty(jsonData, "jobs"));
    long totalItems = getLongValue(jsonJobs, "totalCount");
    JSONObject jsonPageInfo = getObject(getProperty(jsonJobs, "pageInfo"));
    setPageInfoFromJson(jsonPageInfo, paginationModel, totalItems);
    JSONArray jsonEdges = getArray(getProperty(jsonJobs, "edges"));

    for (int i = 0; i < jsonEdges.size(); i++) {
        JSONObject jsonJob = jsonEdges.get(i).isObject();
        Job j = Job.parseJson(jsonJob);
        jobs.put(j.getId(), j);
    }

    return jobs;
}
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:27,代码来源:SchedulerJSONUtils.java

示例4: toMap

import com.google.gwt.json.client.JSONValue; //导入方法依赖的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

示例5: serialize

import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
@Override
public String serialize(Object object) throws SerializerException {
    if (!Utils.isSerializationCapable(object)) {
        throw new SerializerException(
            SerializerException.Error.NOT_SERIALIZABLE);
    }

    JSONValue jsonValue = toJSONValue(object);

    if (jsonValue == null) {
        throw new SerializerException(
            SerializerException.Error.NOT_SERIALIZABLE);
    }

    return jsonValue.toString();
}
 
开发者ID:snogaraleal,项目名称:wbi,代码行数:17,代码来源:JSONSerializer.java

示例6: setJSONValue

import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
@Override
public void setJSONValue(JSONValue value) {
  JSONArray arr = value.isArray();
  if (arr != null) {
    for (int i = 0; i < arr.size(); i++) {
      // We may have to create additional editors
      if (i >= editors.size()) {
        addItem();
      }

      SchemaEditor editor = editors.get(i);
      editor.setJSONValue(arr.get(i));
    }
  } else {
    throw new JSONException("Not a valid JSON array: " + value.toString());
  }
}
 
开发者ID:showlowtech,项目名称:google-apis-explorer,代码行数:18,代码来源:ArraySchemaEditor.java

示例7: getObject

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

示例8: getArray

import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
private static JSONArray getArray(JSONValue value) throws JSONException {
    JSONArray arr = value.isArray();
    if (arr == null) {
        throw new JSONException("Expected JSON Array: " + value.toString());
    }
    return arr;
}
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:8,代码来源:SchedulerJSONUtils.java

示例9: getString

import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
private static String getString(JSONValue value) throws JSONException {
    if (value.isNull() != null) {
        return null;
    }
    JSONString string = value.isString();
    if (string == null) {
        throw new JSONException("Expected JSON String: " + value.toString());
    }
    return string.stringValue();
}
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:11,代码来源:SchedulerJSONUtils.java

示例10: getLongValue

import com.google.gwt.json.client.JSONValue; //导入方法依赖的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

示例11: create

import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
/**
 * Creates one of implementations of {@link EditorPropertyWidget}.
 *
 * @return an instance of {@link EditorPropertyWidget}
 */
public EditorPropertyWidget create(@NotNull String propertyName, @NotNull JSONValue value) {
  if (value.isBoolean() != null) {
    return new EditorBooleanPropertyWidget(propertyName, value.isBoolean().booleanValue());
  }

  if (value.isNumber() != null) {
    Double doubleValue = value.isNumber().doubleValue();
    return new EditorNumberPropertyWidget(propertyName, doubleValue.intValue());
  }
  return new EditorStringPropertyWidget(propertyName, value.toString());
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:EditorPropertyWidgetFactory.java

示例12: setJSONValue

import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
@Override
public void setJSONValue(JSONValue value) {
  JSONString stringVal = value.isString();
  if (stringVal != null) {
    hasText.setText(stringVal.stringValue());
  } else {
    throw new JSONException("Not a valid JSON string: " + value.toString());
  }
}
 
开发者ID:showlowtech,项目名称:google-apis-explorer,代码行数:10,代码来源:SchemaForm.java

示例13: deserialize

import com.google.gwt.json.client.JSONValue; //导入方法依赖的package包/类
public EmpiriaState deserialize(JSONValue stateJson) {

        JSONObject stateObject = stateJson.isObject();

        if (isNewStateObject(stateJson)) {
            EmpiriaStateType type = getStateType(stateObject);
            String state = stateObject.get(EmpiriaState.STATE).isString().stringValue();

            return new EmpiriaState(type, state, getSavedLessonIdentifier(stateObject));
        }

        return new EmpiriaState(EmpiriaStateType.OLD, stateJson.toString(), StringUtils.EMPTY);
    }
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:14,代码来源:EmpiriaStateDeserializer.java


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