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


Java XMLSerializer.read方法代码示例

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


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

示例1: dealPsychicDefine

import net.sf.json.xml.XMLSerializer; //导入方法依赖的package包/类
private void dealPsychicDefine(AGContext core, Map<String, ArbitraryGenProcessor> processors, JSONArray fileArray) {
    if (fileArray == null || fileArray.isEmpty()) {
        Log.i(TAG, "scan out psychic define file list is nil.");
        return;
    }
    ArbitraryGenProcessor psychicProcessor = processors.get("psychic-processor");
    for (int i = 0; i < fileArray.size(); i++) {
        String path = fileArray.optString(i);
        if (Util.isNullOrNil(path)) {
            Log.i(TAG, "file path is null or nil.");
            continue;
        }
        XMLSerializer ss = new XMLSerializer();
        ss.setTypeHintsEnabled(false);
        ss.setTypeHintsCompatibility(false);
        Log.i(TAG, "process src : %s", path);
        String rawContent = FileOperation.read(path);
        JSONObject json = (JSONObject) ss.read(RuntimeContextHelper.replace(rawContent));
        if (json == null) {
            Log.i(TAG, "read JSONObject from XML file(%s) failed.", path);
            continue;
        }
        json = JSONArgsUtils.validKey(json);
        psychicProcessor.exec(core, processors, json);
    }
}
 
开发者ID:AlbieLiang,项目名称:ArbitraryGen,代码行数:27,代码来源:PsychicAGEngine.java

示例2: xml2ArrayForObject

import net.sf.json.xml.XMLSerializer; //导入方法依赖的package包/类
/**
 * 将xml中列表信息转化对象数组
 * 
 * @param xml
 * @param beanClass
 * @return
 */
public static Object[] xml2ArrayForObject(String xml, Class beanClass) {

	// 设置root为数组
	xml = setXmlRootAttrToArray(xml);
	XMLSerializer xmlSer = new XMLSerializer();
	JSON jsonArr = xmlSer.read(xml);
	Object[] objArr = new Object[jsonArr.size()];

	for (int i = 0; i < jsonArr.size(); i++) {
		objArr[i] = JSONObject.toBean(
				((JSONArray) jsonArr).getJSONObject(i), beanClass);
	}

	return objArr;
}
 
开发者ID:thinking-github,项目名称:nbone,代码行数:23,代码来源:JSONXOperUtils.java

示例3: makeAPIRequest

import net.sf.json.xml.XMLSerializer; //导入方法依赖的package包/类
public JSONObject makeAPIRequest(String apiFunction, @Nullable MultivaluedMap<String, String> params) {
    ClientResponse clientResponse = makeAPIResource(apiFunction, params).get(ClientResponse.class);

    log.info(clientResponse.getLocation());

    String response = clientResponse.getEntity(String.class);

    System.out.println(response);
    log.info("response: " + response);

    if (!method.equals("json/")) {
        XMLSerializer xmlSerializer = new XMLSerializer();
        JSON json = xmlSerializer.read(response);

        System.out.println(json);

        return JSONObject.fromObject(json);
    } else
        return JSONObject.fromObject(response);
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:21,代码来源:AbstractApiTest.java

示例4: convertXmlStringToJSon

import net.sf.json.xml.XMLSerializer; //导入方法依赖的package包/类
public JSON convertXmlStringToJSon(String xmlData) {
    JSON json;
    XMLSerializer xmlSerializer = new XMLSerializer();
    xmlSerializer.setForceTopLevelObject(false);
    json = xmlSerializer.read(xmlData);
    return json;
}
 
开发者ID:helicalinsight,项目名称:helicalinsight,代码行数:8,代码来源:XmlOperation.java

示例5: exec

import net.sf.json.xml.XMLSerializer; //导入方法依赖的package包/类
@Override
public JSONObject exec(AGContext context, Map<String, ArbitraryGenProcessor> processors, JSONObject args) {
    String name = args.optString("_name");
    if (Util.isNullOrNil(name)) {
        Log.i(TAG, "exec failed, name is null.");
        return null;
    }
    JSONObject result = context.execProcess(processors, "parse-rule", args);
    if (result == null) {
        Log.i(TAG, "parse rule result is null.");
        return null;
    }
    JSONArray fileArray = result.optJSONArray("fileArray");
    if (fileArray == null) {
        Log.i(TAG, "file array is null.");
        return null;
    }
    JSONArray jsonArray = new JSONArray();
    for (int i = 0; i < fileArray.size(); i++) {
        String path = fileArray.optString(i);
        XMLSerializer ss = new XMLSerializer();
        ss.setTypeHintsEnabled(false);
        ss.setTypeHintsCompatibility(false);
        Log.i(TAG, "process parse xml file : %s", path);
        JSONObject jsonObject = (JSONObject) ss.read(RuntimeContextHelper.replace(FileOperation.read(path)));
        if (jsonObject != null) {
            jsonObject = JSONArgsUtils.validKey(jsonObject);
            jsonArray.add(jsonObject);
        }
    }
    JSONObject r = new JSONObject();
    r.put(name, jsonArray);
    return r;
}
 
开发者ID:AlbieLiang,项目名称:ArbitraryGen,代码行数:35,代码来源:ParseXmlProcessor.java

示例6: process

import net.sf.json.xml.XMLSerializer; //导入方法依赖的package包/类
@Override
public void process(String src, String destPath) {
	if (src == null || destPath == null) {
		throw new RuntimeException(String.format("src file(%s) or dest path(%s) is null.", src, destPath));
	}
	File file = new File(src);
	if (!file.exists() || !file.isFile()) {
		throw new RuntimeException(String.format("src file(%s) do not exist.", src));
	}

	XMLSerializer ss = new XMLSerializer();
	ss.setTypeHintsEnabled(false);
	ss.setTypeHintsCompatibility(false);
	Log.i(TAG, "process src : %s", src);
	JSONObject json = (JSONObject) ss.read(RuntimeContextHelper.replace(FileOperation.read(src)));
	
	TaskInfo info = new TaskInfo();
	info.script = mCoreScript;
	info.destPath = destPath;
	info.templateLibs = mTemplateCfg.getTemplateLibs();
	info.templateSuffix = Util.nullAsNil(Util.getSuffix(src));
	
	for (PsychicGenerator worker : mWorkers) {
		if (worker instanceof AGPsychicWorker) {
			if (info.templateSuffix.equalsIgnoreCase(((AGPsychicWorker) worker).getSupportSuffix())) {
				worker.genCode(mScriptEngine, json, info);
				continue;
			}
		}
		if (worker instanceof AGPyroWorker) {
			if (isSupportSuffix((AGPyroWorker) worker, info.templateSuffix)) {
				worker.genCode(mScriptEngine, json, info);
				continue;
			}
		}
		// Add more case here
	}
}
 
开发者ID:AlbieLiang,项目名称:ArbitraryGen,代码行数:39,代码来源:JsTemplateProcessor.java

示例7: xml2Map

import net.sf.json.xml.XMLSerializer; //导入方法依赖的package包/类
/**
 * 将简单xml中信息转化Map<br>
 * 
 * @param xml
 * @return
 */
public static Map xml2Map(String xml) {
	//案例:
	//<object><id type="string">77777</id><userName type="string">chenyc</userName></object>
	XMLSerializer xmlSer = new XMLSerializer();
	JSON json = xmlSer.read(xml);
	
	return (JSONObject)json;
}
 
开发者ID:thinking-github,项目名称:nbone,代码行数:15,代码来源:JSONXOperUtils.java

示例8: xml2ArrayForMap

import net.sf.json.xml.XMLSerializer; //导入方法依赖的package包/类
/**
 * 将xml中列表信息转化对象数组
 * 
 * @param xml
 * @return
 */
public static Object[] xml2ArrayForMap(String xml) {

	// 设置root为数组
	xml = setXmlRootAttrToArray(xml);
	XMLSerializer xmlSer = new XMLSerializer();
	JSON json = xmlSer.read(xml);
	if(json.isArray()){
		return ((JSONArray) json).toArray();
	}
	return new Object[]{json};
}
 
开发者ID:thinking-github,项目名称:nbone,代码行数:18,代码来源:JSONXOperUtils.java

示例9: ConvertXMLtoJSON

import net.sf.json.xml.XMLSerializer; //导入方法依赖的package包/类
public static String ConvertXMLtoJSON(String xml)  {  
	XMLSerializer xmlSerializer = new XMLSerializer();  
	JSON json =null;
	  
       json = xmlSerializer.read(xml);  
	return json.toString(1);  
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:8,代码来源:Feature.java

示例10: xml2json

import net.sf.json.xml.XMLSerializer; //导入方法依赖的package包/类
/**
 * 将xml字符串<STRONG>转换</STRONG>为JSON字符串
 *
 * @param xmlString
 *            xml字符串
 * @return JSON<STRONG>对象</STRONG>
 */
public static String xml2json(String xmlString) {
    XMLSerializer xmlSerializer = new XMLSerializer();
    JSON json = xmlSerializer.read(xmlString);
    return json.toString(1);
}
 
开发者ID:breakEval13,项目名称:xml2json,代码行数:13,代码来源:XmlExercise.java


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