Java JSONParser.parse方法代码示例

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


Java JSONParser.parse方法代码示例

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

示例1: downloadLibraries

import net.minidev.json.parser.JSONParser; //导入方法依赖的package包/类
public static void downloadLibraries(String file) throws MalformedURLException, ParseException, IOException {
	File launcherProfiles = new File(file + "download\\install_profile.json");
	JSONParser p = new JSONParser();
	JSONObject obj = (JSONObject) p.parse(launcherProfiles.toURL().openStream());
	JSONObject versionInfo = (JSONObject) obj.get("versionInfo");
	JSONArray libraries = (JSONArray) versionInfo.get("libraries");
	for (Object lib2 : libraries) {
		JSONObject lib = (JSONObject) lib2;
		// if (lib.containsKey("clientreq")) {
		// Boolean client = (Boolean) lib.get("clientreq");
		// if (client) {
		String name = (String) lib.get("name");
		if (lib.containsKey("url")) {
			CLUtil.downloadMaven(name, new File(file + "libraries\\"), (String) lib.get("url"));
		} else {
			CLUtil.downloadMaven(name, new File(file + "libraries\\"));
		}
		// }
		// }
	}

	// System.exit(0);
} 
开发者ID:mcNETDev,项目名称:CLauncher,代码行数:24,代码来源:CLUtil.java

示例2: jsonFromString

import net.minidev.json.parser.JSONParser; //导入方法依赖的package包/类
/**
 * Convert <code>jsonString</code> to a {@link JSONObject}
 * @param jsonString
 * @return
 * @throws ServletException
 */
public JSONObject jsonFromString(String jsonString) throws ServletException {
	//environment.logDebug("JSONFROMSTRING "+jsonString);
	//NOTE: there are edge conditions:
	//  jsonString == ""  can happen
	JSONParser p = new JSONParser(JSONParser.MODE_JSON_SIMPLE);
	try {
		return (JSONObject)p.parse(jsonString);
	} catch (Exception e) {
		environment.logError(jsonString, e);
		throw new ServletException(e);
	}
} 
开发者ID:topicquests,项目名称:backside-servlet-ks,代码行数:19,代码来源:BaseHandler.java

示例3: jsonFromString

import net.minidev.json.parser.JSONParser; //导入方法依赖的package包/类
JSONObject jsonFromString(String jsonString) throws ServletException {
	JSONParser p = new JSONParser(JSONParser.MODE_JSON_SIMPLE);
	try {
		return (JSONObject)p.parse(jsonString);
	} catch (Exception e) {
		environment.logError("BadJSON: "+jsonString, e);
		throw new ServletException(e);
	}
} 
开发者ID:topicquests,项目名称:backside-servlet-ks,代码行数:10,代码来源:UploadHelper.java

示例4: testParseRolesEndpoint

import net.minidev.json.parser.JSONParser; //导入方法依赖的package包/类
/**
 * Verify the underlying JSONParser used by TokenUtils
 * @throws Exception
 */
@Test(groups = TEST_GROUP_UTILS)
public void testParseRolesEndpoint() throws Exception {
    JSONParser parser = new JSONParser(DEFAULT_PERMISSIVE_MODE);
    InputStream contentIS = TokenUtils.class.getResourceAsStream("/Token1.json");
    byte[] tmp = new byte[4096];
    int length = contentIS.read(tmp);
    byte[] content = new byte[length];
    System.arraycopy(tmp, 0, content, 0, length);
    JSONObject obj = (JSONObject) parser.parse(content);
    System.out.println(obj);

} 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:17,代码来源:TokenUtilsTest.java

示例5: isJson

import net.minidev.json.parser.JSONParser; //导入方法依赖的package包/类
public static boolean isJson(String str) {
    try {
    	JSONParser parser = new JSONParser();
    	Object obj = parser.parse(str);
    	if (obj instanceof JSONObject)
    		return true;
    	else 
    		return false;
    } catch (Exception e) {
        return false;
    }
} 
开发者ID:ERS-HCL,项目名称:itest-starter,代码行数:13,代码来源:RestUtil.java

示例6: compress

import net.minidev.json.parser.JSONParser; //导入方法依赖的package包/类
/**
 * Reformat Json input keeping element order
 * 
 * @since 1.0.6.2
 */
public static String compress(String input, JSONStyle style) {
    try {
        StringBuilder sb = new StringBuilder();
        ContentHandlerCompressor comp = new ContentHandlerCompressor(sb, style);
        JSONParser p = new JSONParser(DEFAULT_PERMISSIVE_MODE);
        p.parse(input, FACTORY_FAKE_COINTAINER, comp);
        return sb.toString();
    } catch (Exception e) {
        return input;
    }
} 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:17,代码来源:JSONValue.java

示例7: parse

import net.minidev.json.parser.JSONParser; //导入方法依赖的package包/类
/**
 * Parse input json as a mapTo class
 * 
 * mapTo can be a bean
 * 
 * @since 2.0
 */
public static <T> T parse(String in, Class<T> mapTo) {
	try {
		JSONParser p = new JSONParser(DEFAULT_PERMISSIVE_MODE);
		return p.parse(in, defaultReader.getMapper(mapTo));
	} catch (Exception e) {
		return null;
	}
} 
开发者ID:netplex,项目名称:json-smart-v2,代码行数:16,代码来源:JSONValue.java

示例8: compress

import net.minidev.json.parser.JSONParser; //导入方法依赖的package包/类
/**
 * Reformat Json input keeping element order
 * 
 * @since 1.0.6.2
 */
public static String compress(String input, JSONStyle style) {
	try {
		StringBuilder sb = new StringBuilder();
		ContentHandlerCompressor comp = new ContentHandlerCompressor(sb, style);
		JSONParser p = new JSONParser(DEFAULT_PERMISSIVE_MODE);
		p.parse(input, FACTORY_FAKE_COINTAINER, comp);
		return sb.toString();
	} catch (Exception e) {
		return input;
	}
} 
开发者ID:netplex,项目名称:json-smart-v1,代码行数:17,代码来源:JSONValue.java

示例9: testNonFloat

import net.minidev.json.parser.JSONParser; //导入方法依赖的package包/类
public void testNonFloat() throws Exception {
	JSONParser p = new JSONParser(JSONParser.MODE_PERMISSIVE);
	for (String s : FALSE_NUMBERS) {
		String json = "{v:" + s + "}";
		JSONObject obj = (JSONObject) p.parse(json);
		assertEquals("Should be parse as string", s, obj.get("v"));

		String correct = "{\"v\":\"" + s + "\"}";
		assertEquals("Should be re serialized as", correct, obj.toJSONString());
	}
} 
开发者ID:netplex,项目名称:json-smart-v1,代码行数:12,代码来源:TestFloat.java

示例10: testInvalidJson

import net.minidev.json.parser.JSONParser; //导入方法依赖的package包/类
public static void testInvalidJson(String json, int permissifMode, int execptionType, Class<?> cls)
		throws Exception {
	JSONParser p = new JSONParser(permissifMode);
	try {
		if (cls == null)
			p.parse(json);
		else
			p.parse(json, cls);
		TestCase.assertFalse("Exception Should Occure parsing:" + json, true);
	} catch (ParseException e) {
		if (execptionType == -1)
			execptionType = e.getErrorType();
		TestCase.assertEquals(execptionType, e.getErrorType());
	}
} 
开发者ID:netplex,项目名称:json-smart-v2,代码行数:16,代码来源:MustThrows.java

示例11: testInvalidJson

import net.minidev.json.parser.JSONParser; //导入方法依赖的package包/类
public static void testInvalidJson(String json, int permissifMode, int execptionType) throws Exception {
	JSONParser p = new JSONParser(permissifMode);
	try {
		p.parse(json);
		TestCase.assertFalse("Exception Should Occure parsing:" + json, true);
	} catch (ParseException e) {
		if (execptionType == -1)
			execptionType = e.getErrorType();
		TestCase.assertEquals(execptionType, e.getErrorType());
	}
} 
开发者ID:netplex,项目名称:json-smart-v1,代码行数:12,代码来源:MustThrows.java

示例12: testFloat

import net.minidev.json.parser.JSONParser; //导入方法依赖的package包/类
public void testFloat() throws Exception {
	String[] asNumber = new String[] { "1.0", "123.456", "1.0E1", "123.456E12", "1.0E+1", "123.456E+12", "1.0E-1",
			"123.456E-12", "1.0e1", "123.456e12", "1.0e+1", "123.456e+12", "1.0e-1", "123.456e-12" };
	JSONParser p = new JSONParser();
	for (String s : asNumber) {
		String json = "{v:" + s + "}";
		Double val = Double.valueOf(s.trim());
		JSONObject obj = (JSONObject) p.parse(json);
		Object value = obj.get("v");
		assertEquals("Should be parse as double", val, value);
	}
} 
开发者ID:netplex,项目名称:json-smart-v1,代码行数:13,代码来源:TestFloat.java

示例13: AirStruct

import net.minidev.json.parser.JSONParser; //导入方法依赖的package包/类
public AirStruct(String json) throws Exception {
	JSONParser p = new JSONParser(JSONParser.MODE_JSON_SIMPLE);
	data = (JSONObject)p.parse(json);
} 
开发者ID:SolrSherlock,项目名称:OpenSherlockCoreAPI,代码行数:5,代码来源:AirStruct.java

示例14: ChildStruct

import net.minidev.json.parser.JSONParser; //导入方法依赖的package包/类
public ChildStruct(String json) throws Exception {
	JSONParser p = new JSONParser(JSONParser.MODE_JSON_SIMPLE);
	data = (JSONObject)p.parse(json);
} 
开发者ID:SolrSherlock,项目名称:OpenSherlockCoreAPI,代码行数:5,代码来源:ChildStruct.java

示例15: InfoBox

import net.minidev.json.parser.JSONParser; //导入方法依赖的package包/类
public InfoBox(String json) throws Exception {
	JSONParser p = new JSONParser(JSONParser.MODE_JSON_SIMPLE);
	data = (JSONObject)p.parse(json);
} 
开发者ID:SolrSherlock,项目名称:OpenSherlockCoreAPI,代码行数:5,代码来源:InfoBox.java

本文标签属性:

示例:示例的拼音

代码:代码编程

java:java游戏

上一篇:C++ SOC_DOUBLE_TLV函数代码示例
下一篇:Python Mega.get_upload_link方法代码示例

为您推荐