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


Java JSONParser.parseLenient方法代码示例

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


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

示例1: getStyle

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
public static ProjectLayerStyle getStyle(String geoJSONCSS) {
	ProjectLayerStyle style = null;
	final JSONValue jsonValue = JSONParser.parseLenient(geoJSONCSS);
	final JSONObject geoJSONCssObject = jsonValue.isObject();

	if (geoJSONCssObject.containsKey(GeoJSONCSS.STYLE_NAME)) {

		JSONObject styleObject = geoJSONCssObject
				.get(GeoJSONCSS.STYLE_NAME).isObject();

		String fillColor = getStringValue(styleObject, FILL_COLOR_NAME);
		Double fillOpacity = getDoubleValue(styleObject, FILL_OPACITY_NAME);
		if(fillOpacity == null) {
			fillOpacity = getDoubleValue(styleObject, FILL_OPACITY2_NAME);				
		}
		String strokeColor = getStringValue(styleObject, STROKE_COLOR_NAME);
		Double strokeWidth = getDoubleValue(styleObject, STROKE_WIDTH_NAME);

		style = new ProjectLayerStyle(fillColor, fillOpacity, strokeColor,
				strokeWidth);
	}

	return style;
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:25,代码来源:LeafletStyle.java

示例2: parseMap

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
public static <T extends Enum<T>> Map<T, Double> parseMap(Class<T> clazz,
		String text) {
	
	if (text == null) {
		return new TreeMap<T, Double>();
	} else {
	
		JSONValue v = JSONParser.parseLenient(text);
		Map<String, String> smap = JsonUtil.parseMap(v);

		Map<T, Double> map = new TreeMap<T, Double>();

		for (Map.Entry<String, String> e : smap.entrySet()) {
			T type = Enum.valueOf(clazz, e.getKey());
			Double d = Double.parseDouble(e.getValue());
			
			map.put(type, d);
		}

		return map;
	}
}
 
开发者ID:dawg6,项目名称:dhcalc,代码行数:23,代码来源:JsonUtil.java

示例3: parseExternalBookmarks

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
void parseExternalBookmarks() {
    JavaScriptObject externalBookmarks = getExternalBookmarks();
    if (externalBookmarks != null) {
        JSONArray externalState = (JSONArray) JSONParser.parseLenient(externalBookmarks.toString());
        if (externalState.size() > 0) {
            fillBookmarks(externalState);
        }
    }
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:10,代码来源:BookmarkProcessorExtension.java

示例4: parseExternalStickies

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
private void parseExternalStickies() {
    JavaScriptObject externalStickies = getExternalStickies();
    if (externalStickies != null) {
        JSONArray externalState = (JSONArray) JSONParser.parseLenient(externalStickies.toString());
        if (externalState.size() > 0) {
            fillStickies(externalState);
        }
    }

}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:11,代码来源:StickiesProcessorExtension.java

示例5: testDecoding

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
public void testDecoding() throws Exception {
    // given
    final String input = "[\"" + DUMMY_TEXT + "\"]";
    JSONArray incomingState = (JSONArray) JSONParser.parseLenient(input);

    // when
    TextEditorModel actual = testObj.decodeModel(incomingState);

    // then
    assertEquals(model, actual);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:12,代码来源:TextEditorModelEncoderGWTTestCase.java

示例6: Project

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
public Project(String json) {
	final JSONValue jsonValue = JSONParser.parseLenient(json);
	final JSONObject jsonObject = jsonValue.isObject();
	
	String projectDate = jsonObject.get(DATE_NAME).isString().stringValue();
	String projectTitle = jsonObject.get(TITLE_NAME).isString().stringValue();
	String projectVersion = jsonObject.get(VERSION_NAME).isString().stringValue();
	String projectDescription = jsonObject.get(DESCRIPTION_NAME).isString().stringValue();
	
	setDate(projectDate);
	setTitle(projectTitle);
	setVersion(projectVersion);
	setDescription(projectDescription);
	
	JSONArray layersArray = jsonObject.get(VECTORS_NAME).isArray();
	
	if (layersArray != null) {
        for (int i = 0; i < layersArray.size(); i++) {
            JSONObject projectLayerObj = layersArray.get(i).isObject();
            String name = projectLayerObj.get(NAME).isString().stringValue();
            String content = projectLayerObj.get(CONTENT_NAME).isString().stringValue();	            
            JSONObject styleProjectLayer = projectLayerObj.get(STYLE_NAME).isObject();
            
            String fillColor = styleProjectLayer.get(ProjectLayerStyle.FILL_COLOR_NAME).isString().stringValue();
            Double fillOpacity = styleProjectLayer.get(ProjectLayerStyle.FILL_OPACITY_NAME).isNumber().doubleValue();
            String strokeColor = styleProjectLayer.get(ProjectLayerStyle.STROKE_COLOR_NAME).isString().stringValue();
            Double strokeWidth = styleProjectLayer.get(ProjectLayerStyle.STROKE_WIDTH_NAME).isNumber().doubleValue();
            
            add(name, content, fillColor, fillOpacity, strokeColor, strokeWidth);	           
        }
	
	}
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:34,代码来源:Project.java

示例7: getLayerStyle

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
public VectorStyleDef getLayerStyle(String vectorFormatString) {
	VectorFeatureStyleDef def = null;
	
	final JSONValue jsonValue = JSONParser.parseLenient(vectorFormatString);
	final JSONObject geoJSONCssObject = jsonValue.isObject();

	if (geoJSONCssObject.containsKey(GeoJSONCSS.STYLE_NAME)) {

		JSONObject styleObject = geoJSONCssObject.get(GeoJSONCSS.STYLE_NAME).isObject();
		JSObject styleJSObject = styleObject.getJavaScriptObject().cast();
		def = getStyleDef(styleJSObject);
	}

	return def;
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:16,代码来源:GeoJSONCSS.java

示例8: setStoredTemplateUrls

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
/**
 * Sets the dynamic template Urls from a jsonStr.  This method is
 * called during start up where jsonStr is retrieved from User
 * settings.
 *
 * @param jsonStr
 */
public static void setStoredTemplateUrls(String jsonStr) {
  if (jsonStr == null || jsonStr.length() == 0)
    return;
  JSONValue jsonVal = JSONParser.parseLenient(jsonStr);
  JSONArray jsonArr = jsonVal.isArray();
  for (int i = 0; i < jsonArr.size(); i++) {
    JSONValue value = jsonArr.get(i);
    JSONString str = value.isString();
    dynamicTemplateUrls.add(str.stringValue());
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:19,代码来源:TemplateUploadWizard.java

示例9: getTemplates

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
/**
 * Returns a list of Template objects containing data needed
 *  to load a template from a zip file. Each non-null template object
 *  is created from its Json string
 *
 * @return ArrayList of TemplateInfo objects
 */
protected static ArrayList<TemplateInfo> getTemplates() {
  JSONValue jsonVal = JSONParser.parseLenient(templateDataString);
  JSONArray jsonArr = jsonVal.isArray();
  ArrayList<TemplateInfo> templates = new ArrayList<TemplateInfo>();
  for (int i = 0; i < jsonArr.size(); i++) {
    JSONValue value = jsonArr.get(i);
    JSONObject obj = value.isObject();
    if (obj != null)
      templates.add(new TemplateInfo(obj)); // Create TemplateInfo from Json
  }
  return templates;
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:20,代码来源:TemplateUploadWizard.java

示例10: parseFormData

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
public static FormData parseFormData(String text) {
	FormData data = new FormData();
	
	if ((text != null) && (text.trim().length() > 0)) {
	
		try {
			JSONValue value = JSONParser.parseLenient(text);
			
			if (value != null) {
				JSONObject obj = value.isObject();
			
				if (obj != null) {
					data.version = JsonUtil.parseVersion(obj.get("version"));
					data.main = JsonUtil.parseMap(obj.get("main"));
					data.calculator = JsonUtil.parseMap(obj.get("calculator"));
					data.items = JsonUtil.parseMap(obj.get("items"));
					data.passives = JsonUtil.parseMap(obj.get("passives"));
					data.gems = JsonUtil.parseMap(obj.get("gems"));
					data.specialItems = JsonUtil.parseMap(obj.get("equipment"));
					data.skills = JsonUtil.parseMap(obj.get("skills"));
					data.elementalDamage = JsonUtil.parseMap(obj.get("elementalDamage"));
					data.skillDamage = JsonUtil.parseMap(obj.get("skillDamage"));
					data.hero = null;
					data.career = null;
				}
			}
		} catch (Exception e) {
			ApplicationPanel.showErrorDialog("Error Parsing Form Data");
			GWT.log("Error Parsing JSON Data", e);
		}
		
		
	}
	
	return data;
}
 
开发者ID:dawg6,项目名称:dhcalc,代码行数:37,代码来源:JsonUtil.java

示例11: parseSet

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
public static <T extends Enum<T>> Set<T> parseSet(Class<T> clazz, String text) {
	if ((text == null) || (text.trim().length() == 0))
		return null;
	
	Set<T> set = new TreeSet<T>();

	JSONValue value = JSONParser.parseLenient(text);

	JSONArray array = value.isArray();
	
	if (array == null)
		return null;
	
	for (int i = 0; i < array.size(); i++) {
		JSONValue e = array.get(i);
		
		if (e  != null) {
			JSONString str = e.isString();
			
			if (str != null) {
				String name = str.stringValue();
				
				if (name != null) {
					T elem = Enum.valueOf(clazz, name);
					
					if (elem != null) {
						set.add(elem);
					}
				}
			}
		}
	}
	
	
	return set;
}
 
开发者ID:dawg6,项目名称:dhcalc,代码行数:37,代码来源:JsonUtil.java

示例12: parseGemsMap

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
public static Map<GemSkill, GemAttributeData> parseGemsMap(String text) {
	if (text == null) {
		return new TreeMap<GemSkill, GemAttributeData>();
	} else {
	
		JSONValue v = JSONParser.parseLenient(text);
		Map<String, String> smap = JsonUtil.parseMap(v);

		return Util.createGems(smap);
	}
}
 
开发者ID:dawg6,项目名称:dhcalc,代码行数:12,代码来源:JsonUtil.java

示例13: parseSpecialItemsMap

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
public static Map<Slot, ItemHolder> parseSpecialItemsMap(String text) {
	if (text == null) {
		return new TreeMap<Slot, ItemHolder>();
	} else {
	
		JSONValue v = JSONParser.parseLenient(text);
		Map<String, String> smap = JsonUtil.parseMap(v);

		return Util.createSpecialItems(smap);
	}
}
 
开发者ID:dawg6,项目名称:dhcalc,代码行数:12,代码来源:JsonUtil.java

示例14: parseSetCounts

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
public static Map<String, Integer> parseSetCounts(String text) {
	if (text == null) {
		return new TreeMap<String, Integer>();
	} else {
	
		JSONValue v = JSONParser.parseLenient(text);
		Map<String, String> smap = JsonUtil.parseMap(v);

		return Util.createSetCounts(smap);
	}
}
 
开发者ID:dawg6,项目名称:dhcalc,代码行数:12,代码来源:JsonUtil.java

示例15: onCustomRowAction

import com.google.gwt.json.client.JSONParser; //导入方法依赖的package包/类
@Override
protected void onCustomRowAction(RowActionEvent<String> event) {
  Integer verifierId = Integer.valueOf(event.getClickedId());
  final int action = event.getAction();
  AsyncCallback<UserVerifierDto> callback = new AsyncCallback<UserVerifierDto>() {
    @Override
    public void onFailure(Throwable caught) {
      Utils.handleException(caught, listView);
    }

    @Override
    public void onSuccess(UserVerifierDto key) {

      String jsonConfig = key.getJsonConfiguration();

      JSONObject json;
      //Some verifiers (ex:Trustful) has no jsonConfiguration field
      if (jsonConfig != null && !jsonConfig.isEmpty()) {
        json = (JSONObject) JSONParser.parseLenient(jsonConfig);
      } else {
        json = new JSONObject();
      }

      json.put("pluginTypeName", new JSONString(key.getPluginTypeName()));
      json.put("pluginClassName", new JSONString(key.getPluginClassName()));

      ServletHelper.downloadJsonFile(json.toString(), key.getPluginTypeName() + ".json");
    }
  };

  switch (action) {
    case KaaRowAction.DOWNLOAD_SCHEMA:
      KaaAdmin.getDataSource().getUserVerifier(String.valueOf(verifierId), callback);
      break;
    default:
      break;
  }
}
 
开发者ID:kaaproject,项目名称:kaa,代码行数:39,代码来源:UserVerifiersActivity.java


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