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


Java JSONValue.parse方法代码示例

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


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

示例1: MongoHandler

import org.json.simple.JSONValue; //导入方法依赖的package包/类
public MongoHandler(Socket client, Request req, MongoClient mongoconn) throws Exception {
    Object obj = JSONValue.parse(req.getContent());
    JSONObject jobj = (JSONObject)obj;
    System.out.println(req.getContent());
    if((database = (String)jobj.get("database")) == null) {
        throw new Exception("Database not specified");
    }
    if((collection = (String)jobj.get("collection")) == null){
        throw new Exception("Collection not specified");
    }
    if((operation = (String)jobj.get("operation")) == null){
        throw new Exception("Operation not specified");
    }
    data = (JSONObject)jobj.get("data");
    this.dbconn = mongoconn;

    mdb = dbconn.getDatabase(database);
    mcollection = mdb.getCollection(collection);
    this.client = client;
}
 
开发者ID:aninditamondal,项目名称:FireAnt,代码行数:21,代码来源:MongoHandler.java

示例2: getPageMap

import org.json.simple.JSONValue; //导入方法依赖的package包/类
/**
    * parse and map the pages and its page timings
    *
    * @param data json data
    * @return json map
    */
  
private static JSONObject getPageMap(String data) {
       JSONObject pageMap = new JSONObject();
       JSONObject ob = (JSONObject) JSONValue.parse(data);
       for (Object tc : ob.keySet()) {
           JSONArray hars = (JSONArray) ((JSONObject) ob.get(tc)).get("har");
           for (Object e : hars) {
               JSONObject har = (JSONObject) ((JSONObject) e).get("har");
               JSONObject page = (JSONObject) ((JSONArray) (((JSONObject) har.get("log")).get("pages"))).get(0);
               Object pagename = ((JSONObject) har.get("config")).get("name");
               if (!pageMap.containsKey(pagename)) {
                   pageMap.put(pagename, new JSONArray());
               }
               JSONObject pageData = (JSONObject) page.get("pageTimings");
               pageData.put("config", har.get("config"));
               ((JSONArray) pageMap.get(pagename)).add(pageData);
           }
       }
       return pageMap;
   }
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:27,代码来源:Performance.java

示例3: readCommandLineOpts

import org.json.simple.JSONValue; //导入方法依赖的package包/类
public static Map readCommandLineOpts() {
	Map ret = new HashMap();
	String commandOptions = System.getProperty("leaf.options");
	if (commandOptions != null) {
		String[] configs = commandOptions.split(",");
		for (String config : configs) {
			config = URLDecoder.decode(config);
			String[] options = config.split("=", 2);
			if (options.length == 2) {
				Object val = JSONValue.parse(options[1]);
				if (val == null) {
					val = options[1];
				}
				ret.put(options[0], val);
			}
		}
	}
	return ret;
}
 
开发者ID:weizhenyi,项目名称:leaf-snowflake,代码行数:20,代码来源:Utils.java

示例4: authFacebookLogin

import org.json.simple.JSONValue; //导入方法依赖的package包/类
public FbLoginInfo authFacebookLogin(String accessToken) {
FbLoginInfo fbLoginInfo = null;
      try {
      	JSONObject jsonmap = (JSONObject) JSONValue.parse(
          		readURL(new URL("https://graph.facebook.com/me?access_token=" + accessToken)));
      	fbLoginInfo = new FbLoginInfo(); 
      	fbLoginInfo.id = (String)jsonmap.get("id");
      	fbLoginInfo.firstName = (String)jsonmap.get("first_name");
      	fbLoginInfo.lastName = (String)jsonmap.get("last_name");
      	fbLoginInfo.email = (String)jsonmap.get("email");
      	logger.info("Facebook login : id=" + fbLoginInfo.id + " fname=" + fbLoginInfo.firstName + " lastname=" + 
      			fbLoginInfo.lastName + " email=" + fbLoginInfo.email);
      } catch (Throwable ex) {
          logger.warn("Facebook login failed for token " + accessToken);
      }
      return fbLoginInfo;
  }
 
开发者ID:kenfrank,项目名称:trivolous,代码行数:18,代码来源:Facebook.java

示例5: connect

import org.json.simple.JSONValue; //导入方法依赖的package包/类
private boolean connect() {
     try {
         final URLConnection connection = this.url.openConnection();
         connection.setConnectTimeout(5000);
         connection.addRequestProperty("User-Agent", "CS-CoreLib Loader (by mrCookieSlime)");
         connection.setDoOutput(true);

         final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
         final JSONArray array = (JSONArray) JSONValue.parse(reader.readLine());
         download = traceURL(((String) ((JSONObject) array.get(array.size() - 1)).get("downloadUrl")).replace("https:", "http:"));
         file = new File("plugins/" + (String) ((JSONObject) array.get(array.size() - 1)).get("name") + ".jar");
         
         return true;
     } catch (IOException e) {
     	System.err.println(" ");
     	System.err.println("#################### - WARNING - ####################");
System.err.println(" ");
System.err.println("Could not connect to BukkitDev.");
System.err.println("Please download & install CS-CoreLib manually:");
System.err.println("https://dev.bukkit.org/projects/cs-corelib");
System.err.println(" ");
System.err.println("#################### - WARNING - ####################");
System.err.println(" ");
         return false;
     }
 }
 
开发者ID:TheBusyBiscuit,项目名称:CS-CoreLib,代码行数:27,代码来源:CSCoreLibLoader.java

示例6: appendString

import org.json.simple.JSONValue; //导入方法依赖的package包/类
public void appendString(String jsonObject){
	Object obj = JSONValue.parse(jsonObject);
	if (obj instanceof JSONObject){
		workingGroup.add((JSONObject)obj);
	}
	if (obj instanceof JSONArray){
		for (Object object:((JSONArray)obj)){
			if (object.toString().isEmpty()) continue;
			if (object instanceof JSONArray){
				appendString(object.toString());
			} else {
				workingGroup.add((JSONObject)JSONValue.parse(object.toString()));	
			}
		}			
	}
}
 
开发者ID:FabioZumbi12,项目名称:UltimateChat,代码行数:17,代码来源:UltimateFancy.java

示例7: jsonQuery

import org.json.simple.JSONValue; //导入方法依赖的package包/类
public Object jsonQuery(String postfix) throws IOException {
    URL url = new URL(SITE_PREFIX + spigetId + postfix);
    URLConnection conn = url.openConnection();
    conn.setRequestProperty("User-Agent", USER_AGENT);
    if(((HttpURLConnection)conn).getResponseCode() == 404)
        return null;
    return JSONValue.parse(new InputStreamReader((InputStream)conn.getContent()));
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:9,代码来源:SpigetUpdateChecker.java

示例8: main

import org.json.simple.JSONValue; //导入方法依赖的package包/类
public static void main(String args[]) throws ParserConfigurationException, IOException, TransformerException {
	Reader reader = new FileReader(args[0]);
	Object object = JSONValue.parse(reader);
	reader.close();
	DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
	DocumentBuilder docBuilder = dbf.newDocumentBuilder();
	Document doc = toXML(docBuilder, object);
	TransformerFactory transformerFactory = TransformerFactory.newInstance();
	Transformer transformer = transformerFactory.newTransformer();
	Source source = new DOMSource(doc);
	Result result = new StreamResult(new File(args[1]));
	transformer.transform(source, result);
}
 
开发者ID:Bibliome,项目名称:bibliome-java-utils,代码行数:14,代码来源:JSONUtils.java

示例9: getCode

import org.json.simple.JSONValue; //导入方法依赖的package包/类
/**
 * 例外発生時のステータスコードを取得.
 * @return ステータスコード
 */
public final String getCode() {
    String code = "";
    String msg = this.getMessage();
    JSONObject json = (JSONObject) JSONValue.parse(msg);
    code = (String) json.get("code");
    return code;
}
 
开发者ID:personium,项目名称:personium-core,代码行数:12,代码来源:PersoniumException.java

示例10: readJsonFromUrl

import org.json.simple.JSONValue; //导入方法依赖的package包/类
public static JSONObject readJsonFromUrl(String url) {
	try {
		InputStream is = new URL(url).openStream();
		BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
		String jsonText = readAll(rd);
		JSONObject json = (JSONObject) JSONValue.parse(jsonText);
		is.close();
		return json;
	} catch (Exception e) {
		e.printStackTrace();
	}
	
	return null;
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:15,代码来源:JsonReader.java

示例11: process

import org.json.simple.JSONValue; //导入方法依赖的package包/类
@Override
public void process(ProcessingContext<Corpus> ctx, Corpus corpus) throws ModuleException {
	try {
		AlvisAEExportResolvedObjects resObj = getResolvedObjects();
		CadixeExportContext exportContext = new CadixeExportContext(ctx);
		if (schemaFile != null) {
			Reader r = new FileReader(schemaFile);
			exportContext.schema = JSONValue.parse(r);
			if (exportContext.schema == null)
				processingException("could not parse " + schemaFile + " as JSON");
			r.close();
		}
		for (Document doc : Iterators.loop(documentIterator(exportContext.evalCtx, corpus))) {
			JSONObject json = documentToJSON(doc, exportContext);
			OutputFile outFile = new OutputFile(outDir, resObj.fileName.evaluateString(exportContext.evalCtx, doc));
			TargetStream target = new FileTargetStream("UTF-8", outFile);
			Writer w = target.getWriter();
			json.writeJSONString(w);
			w.close();
		}
	}
	catch (UnsupportedEncodingException uee) {
		rethrow(uee);
	}
	catch (FileNotFoundException fnfe) {
		rethrow(fnfe);
	}
	catch (IOException ioe) {
		rethrow(ioe);
	}
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:32,代码来源:AlvisAEWriter.java

示例12: parse

import org.json.simple.JSONValue; //导入方法依赖的package包/类
public Map<String, Object> parse(String activityType, String activitySummary) throws JSONException
{
	JSONObject json = (JSONObject)JSONValue.parse(activitySummary);
	Map<String, Object> map = convertJSONObjectToMap(json);
	processActivitySummary(activityType, map);
	return map;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:8,代码来源:ActivitySummaryParser.java

示例13: init

import org.json.simple.JSONValue; //导入方法依赖的package包/类
public void init() {
    try {
        String rawData = FileScanner.readFile(new File(getFile()));
        this.data = (JSONObject) JSONValue.parse(rawData);
    } catch (Exception ex) {
        LOG.error(ex.getMessage(), ex);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:9,代码来源:ReportingModuleSettings.java

示例14: getRefData

import org.json.simple.JSONValue; //导入方法依赖的package包/类
public static JSONObject getRefData(JSONObject req) {
    try {
        String data = Tools.readFile(new File(DashBoardData.refHars(), req.get("name").toString() + ".har.ref"));
        return (JSONObject) JSONValue.parse(data);
    } catch (Exception ex) {
        LOG.log(Level.WARNING, "Error while reading har ref file", ex);
    }
    return null;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:10,代码来源:HarCompareHandler.java

示例15: parseActivitySummary

import org.json.simple.JSONValue; //导入方法依赖的package包/类
private Map<String, Object> parseActivitySummary(ActivityFeedEntity entity)
{
	String activityType = entity.getActivityType();
	String activitySummary = entity.getActivitySummary();
	JSONObject json = (JSONObject)JSONValue.parse(activitySummary);
	return Activity.getActivitySummary(json, activityType);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:8,代码来源:RepoService.java


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