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


Java JSONParser.parseStrict方法代码示例

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


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

示例1: toList

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

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

示例3: parseGadgetInfoJson

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
@Override
public List<GadgetInfo> parseGadgetInfoJson(String json) {
  List<GadgetInfo> gadgetList = new ArrayList<GadgetInfo>();
  JSONValue value = JSONParser.parseStrict(json);
  JSONArray array = value.isArray();
  if (array != null) {
    for (int i = 0; i < array.size(); i++) {
      JSONValue item = array.get(i);
      GadgetInfo info = parseGadgetInfo(item);
      if (info != null) {
        gadgetList.add(info);
      }
    }
  }
  return gadgetList;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:17,代码来源:GwtGadgetInfoParser.java

示例4: toMap

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

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

  JSONValue parsed = JSONParser.parseStrict(jsonStr);
  JSONObject jsonObj = parsed.isObject();
  if (jsonObj != null) {
    for (String key : jsonObj.keySet()) {
      JSONValue jsonValue = jsonObj.get(key);
      JSONArray jsonArray = jsonValue.isArray();

      List<String> values = new ArrayList<>();
      for (int i = 0; i < jsonArray.size(); i++) {
        values.add(jsonArray.get(i).isString().stringValue());
      }
      map.put(key, values);
    }
  }

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

示例6: deserialize

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
@Override
public Object deserialize(String payload, Type expected)
    throws SerializerException {

    JSONValue jsonValue = JSONParser.parseStrict(payload);

    try {
        Object object = fromJSONValue(jsonValue, expected);

        if (object == null) {
            throw new SerializerException(
                SerializerException.Error.NOT_DESERIALIZABLE);
        }

        return object;

    } catch (NoSuitableSerializableFactory exception) {
        throw new SerializerException(
            SerializerException.Error.NOT_DESERIALIZABLE, exception);
    }
}
 
开发者ID:snogaraleal,项目名称:wbi,代码行数:22,代码来源:JSONSerializer.java

示例7: init

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
public void init() {
	// try to get the serialized representation of the SQLite DB from the
	// local storage
	String serializedDb = storage.getItem(LOCALSTORAGE_KEY_DB);

	if (serializedDb == null || serializedDb.isEmpty()) {
		// if nothing is found, we create the database from scratch
		sqlDb = SQLite.create();

		// and inject the SQL file which creates the tables structure
		DbSchema dbSchema = (DbSchema) GWT.create(DbSchema.class);
		sqlDb.execute(dbSchema.sqlForSchema().getText());
	} else {
		// if the local storage already contains some data, parse it as a
		// JSON integer array
		JSONValue dbContent = JSONParser.parseStrict(serializedDb);

		// and initialize SQLite with this "file"
		sqlDb = SQLite.create(dbContent.isArray().getJavaScriptObject()
				.<JsArrayInteger> cast());
	}

	persistDB();
	getMinIdPasswd();
	getMinIdField();
}
 
开发者ID:guiguib,项目名称:yaph,代码行数:27,代码来源:DataAccess.java

示例8: onResponseReceived

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
public final void onResponseReceived(final Request request, final Response response) {
  final String text = response.getText();
  if (text.isEmpty()) {
    final int code = response.getStatusCode();
    final String errmsg;
    if (code == 0) {  // Happens when a cross-domain request fails to connect.
      errmsg = ("Failed to connect to " + server + ", check that the server"
                + " is up and that you can connect to it.");
    } else {
      errmsg = ("Empty response from server: code=" + code
                + " status=" + response.getStatusText());
    }
    onError(request, new RuntimeException(errmsg));
  } else {
    JSONValue value;
    try {
      value = JSONParser.parseStrict(text);
    } catch (JSONException e) {
      onError(request, e);
      return;
    }
    onSuccess(value);
  }
}
 
开发者ID:tsuna,项目名称:droopy,代码行数:25,代码来源:Main.java

示例9: isValidJSON

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
public boolean isValidJSON(String json) {
    boolean valid = true;
    try {
        JSONParser.parseStrict(json);
    } catch (Exception exc) {
        valid = false;
    }
    return valid;
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:10,代码来源:OverlayTypesParser.java

示例10: onSuccess

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

示例11: onSuccess

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

示例12: GWTFileUploadResponse

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
/**
 * GWTFileUploadResponse
 *
 * @param text json encoded parameters.
 */
public GWTFileUploadResponse(String text) {
	text = text.substring(text.indexOf("{"));
	text = text.substring(0, text.lastIndexOf("}") + 1);
	JSONValue responseValue = JSONParser.parseStrict(text);
	JSONObject response = responseValue.isObject();

	// Deserialize information
	hasAutomation = response.get("hasAutomation").isBoolean().booleanValue();
	path = URL.decodeQueryString(response.get("path").isString().stringValue());
	error = response.get("error").isString().stringValue();
	showWizardCategories = response.get("showWizardCategories").isBoolean().booleanValue();
	showWizardKeywords = response.get("showWizardKeywords").isBoolean().booleanValue();
	digitalSignature = response.get("digitalSignature").isBoolean().booleanValue();

	// Getting property groups
	JSONArray groupsArray = response.get("groupsList").isArray();

	if (groupsArray != null) {
		for (int i = 0; i <= groupsArray.size() - 1; i++) {
			groupsList.add(groupsArray.get(i).isString().stringValue());
		}
	}

	// Getting workflows
	JSONArray workflowArray = response.get("workflowList").isArray();

	if (workflowArray != null) {
		for (int i = 0; i <= workflowArray.size() - 1; i++) {
			workflowList.add(workflowArray.get(i).isString().stringValue());
		}
	}
}
 
开发者ID:openkm,项目名称:document-management-system,代码行数:38,代码来源:GWTFileUploadResponse.java

示例13: parseJSON

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
/**
 * Parse a JSON string
 * <p>
 * If the input is not valid JSON or parsing fails for some reason,
 * the exception will be logged in the UI but not thrown.
 * 
 * @param jsonStr a valid JSON string
 * @return a java representation of the JSON object hierarchy,
 *     or a JSONObject representing {} if parsing fails
 */
public JSONValue parseJSON(String jsonStr) {
    try {
        return JSONParser.parseStrict(jsonStr);
    } catch (Throwable t) {
        // only shows up in eclipse dev mode
        t.printStackTrace();

        LogModel.getInstance().logCriticalMessage("JSON Parser failed " + t.getClass().getName() + ": " +
                                                  t.getLocalizedMessage());
        LogModel.getInstance().logCriticalMessage("input was: " + jsonStr);
        return new JSONObject();
    }
}
 
开发者ID:ow2-proactive,项目名称:scheduling-portal,代码行数:24,代码来源:Controller.java

示例14: readPreferencesFromJson

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
private static Map<String, JSONValue> readPreferencesFromJson(String jsonPreferences) {
  Map<String, JSONValue> result = new HashMap<>();
  JSONValue parsed = JSONParser.parseStrict(jsonPreferences);

  JSONObject jsonObj = parsed.isObject();
  if (jsonObj != null) {
    jsonObj.keySet().forEach(key -> result.put(key, jsonObj.get(key)));
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:EditorPreferencesManager.java

示例15: readPropertiesFromJson

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
private static Map<String, JSONValue> readPropertiesFromJson(String jsonProperties) {
  Map<String, JSONValue> result = new HashMap<>();
  JSONValue parsed = JSONParser.parseStrict(jsonProperties);

  JSONObject jsonObj = parsed.isObject();
  if (jsonObj != null) {
    for (String key : jsonObj.keySet()) {
      JSONValue jsonValue = jsonObj.get(key);
      result.put(key, jsonValue);
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:EditorPropertiesManager.java


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