• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JsonXMLInputFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中de.odysseus.staxon.json.JsonXMLInputFactory的典型用法代码示例。如果您正苦于以下问题:Java JsonXMLInputFactory类的具体用法?Java JsonXMLInputFactory怎么用?Java JsonXMLInputFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JsonXMLInputFactory类属于de.odysseus.staxon.json包,在下文中一共展示了JsonXMLInputFactory类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: call

import de.odysseus.staxon.json.JsonXMLInputFactory; //导入依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {                     
  try {
    String json = ((StringValue) arguments[0].head()).getStringValue();
    if (StringUtils.isBlank(json)) {
      return EmptySequence.getInstance();
    }        
    XMLInputFactory factory = new JsonXMLInputFactory();                
    XMLStreamReader reader = factory.createXMLStreamReader(new StringReader(json));        
    StAXSource source = new StAXSource(reader);        
    Configuration config = context.getConfiguration();        
    PipelineConfiguration pipe = config.makePipelineConfiguration();
    pipe.getParseOptions().getParserFeatures().remove("http://apache.org/xml/features/xinclude");        
    TinyBuilder builder = new TinyBuilder(pipe);        
    SerializerFactory sf = config.getSerializerFactory();
    Receiver receiver = sf.getReceiver(builder, pipe, new Properties());               
    NamespaceReducer reducer = new NamespaceReducer(receiver);
    ParseOptions options = pipe.getParseOptions();
    options.setContinueAfterValidationErrors(true);
    Sender.send(source, reducer, options);                             
    return builder.getCurrentRoot();                
  } catch (Exception e) {
    throw new XPathException("Error parsing JSON string", e);
  }                    
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:26,代码来源:ParseJSON.java


示例2: convertJsonToXml

import de.odysseus.staxon.json.JsonXMLInputFactory; //导入依赖的package包/类
/**
 * Converts json to xml.
 *
 * @param json json as byte array.
 * @return xml as byte array.
 */
public byte[] convertJsonToXml(byte[] json) {
    JsonXMLConfig config = new JsonXMLConfigBuilder()
        .prettyPrint(true)
        .multiplePI(false)
        .build();
    XMLInputFactory reader = new JsonXMLInputFactory(config);
    XMLOutputFactory writer = XMLOutputFactory.newInstance();
    return convert(reader, writer, json);
}
 
开发者ID:eea,项目名称:eionet.webq,代码行数:16,代码来源:JsonXMLBidirectionalConverter.java


示例3: DepthFirstJSONParser

import de.odysseus.staxon.json.JsonXMLInputFactory; //导入依赖的package包/类
public DepthFirstJSONParser(String repeatingObjectName, InputStream inputStream){
    this.repeatingObjectName = repeatingObjectName;
    nameStack = new Stack<String>();
    this.pairsArchetype = new ArrayList<Pair>();
    JsonXMLInputFactory factory = new JsonXMLInputFactory();
    try {
        this.reader = factory.createXMLStreamReader(inputStream);
    } catch (Exception e) {
        this.exceptionCreatingStreamReader = e;
        this.reader = null;
    }
}
 
开发者ID:Sotera,项目名称:zephyr,代码行数:13,代码来源:DepthFirstJSONParser.java


示例4: load

import de.odysseus.staxon.json.JsonXMLInputFactory; //导入依赖的package包/类
public void load(InputStream input) throws IOException, XMLStreamException {
	XMLInputFactory factory = new JsonXMLInputFactory(new JsonXMLConfigBuilder().virtualRoot("assetStore").build());
	XMLStreamReader reader = factory.createXMLStreamReader(input);
	try {
		if (reader.getEventType() == XMLStreamConstants.START_DOCUMENT) {
			reader.nextTag();
		}
		reader.require(XMLStreamConstants.START_ELEMENT, null, "assetStore");
		reader.nextTag();
		while (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
			switch (reader.getLocalName()) {
			case "version":
				String version = reader.getElementText();
				if (!this.version.equals(version)) {
					throw new IOException("incompatible store version");
				}
				break;
			case "timestamp":
				timestamp = Long.valueOf(reader.getElementText());
				break;
			case "asset":
				AssetEntity entity = loadEntity(reader);
				if (entity != null) {
					entities.put(entity.asset.getResource(), entity);
					if (LOGGER.isLoggable(Level.FINEST)) {
						LOGGER.finest("Asset has been loaded: " + entity.asset.getResource().getPath().toAbsolutePath());
					}
				}
				break;
			case "retina":
				retina = Boolean.valueOf(reader.getElementText());
				break;
			default:
				throw new XMLStreamException("unexpected store property: " + reader.getLocalName());
			}
			reader.require(XMLStreamConstants.END_ELEMENT, null, null);
			reader.nextTag();
		}
		reader.require(XMLStreamConstants.END_ELEMENT, null, "assetStore");
	} finally {
		reader.close();
	}
}
 
开发者ID:beckchr,项目名称:musicmount,代码行数:44,代码来源:AssetStore.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XMLDocumentScannerImpl类代码示例发布时间:2022-05-23
下一篇:
Java ListGridField类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap