当前位置: 首页 > news >正文

做网站的越来越少了松江品划网站建设开发

做网站的越来越少了,松江品划网站建设开发,互联网公司排名2021南方财富网,hui怎么做网站我们正在向EclipseLink MOXy添加从域模型生成JSON模式的 功能 。 为此#xff0c;我们创建了一个新的变量节点映射。 在本文中#xff0c;我将通过将Java模型映射到JSON模式来演示新的映射。 您可以使用每晚构建的EclipseLink 2.6.0进行尝试#xff1a; http://www.eclips… 我们正在向EclipseLink MOXy添加从域模型生成JSON模式的 功能 。 为此我们创建了一个新的变量节点映射。 在本文中我将通过将Java模型映射到JSON模式来演示新的映射。 您可以使用每晚构建的EclipseLink 2.6.0进行尝试 http://www.eclipse.org/eclipselink/downloads/nightly.php JSON模式input.json / Output 以下是摘自http://json-schema.org/examples.html的“基本示例”。 请注意该类型具有许多属性但它们不会显示为JSON数组。 相反它们显示为键入在属性名称上的单独的JSON对象。 {title: Example Schema,type: object,properties: {firstName: {type: string},lastName: {type: string},age: {description: Age in years,type: integer,minimum: 0}},required: [firstName, lastName] }Java模型 以下是我们将用于此示例的Java模型。 JsonSchema存储在列表中的属性 在这种JSON模式的Java表示中我们有一个包含Property对象集合的类。 而不是集合的默认表示形式请参阅 绑定到JSONXML –处理集合 我们希望每个Property以其名称为键。 我们可以使用XmlVariableNode批注进行此操作。 通过它我们可以指定目标对象的字段/属性该字段/属性应用作键。 package blog.variablenode.jsonschema;import java.util.*; import javax.xml.bind.annotation.*; import org.eclipse.persistence.oxm.annotations.XmlVariableNode;XmlAccessorType(XmlAccessType.FIELD) public class JsonSchema {private String title;private String type;XmlElementWrapperXmlVariableNode(name)public ListProperty properties;private ListString required;} JsonSchema存储在地图中的属性 在此版本的JsonSchema类中我们将属性的类型从List Property属性更改为Map StringProperty 。 注释保持不变所不同的是当XmlVariableNode是在地图中使用的变量节点名称作为地图的关键。 package blog.variablenode.jsonschema;import java.util.*; import javax.xml.bind.annotation.*; import org.eclipse.persistence.oxm.annotations.XmlVariableNode;XmlAccessorType(XmlAccessType.FIELD) public class JsonSchema {private String title;private String type;XmlElementWrapperXmlVariableNode(name)public MapString, Property properties;private ListString required;} 属性 为了防止将名称字段编组我们需要使用XmlTransient对其进行注释请参见JAXB和Unmapped属性 。 package blog.variablenode.jsonschema;import javax.xml.bind.annotation.*;XmlAccessorType(XmlAccessType.FIELD) public class Property {XmlTransientprivate String name;private String description;private String type;private Integer minimum;}示范代码 下面是一些示例代码您可以用来证明一切正常。 package blog.variablenode.jsonschema;import java.util.*; import javax.xml.bind.*; import javax.xml.transform.stream.StreamSource; import org.eclipse.persistence.jaxb.JAXBContextProperties;public class Demo {public static void main(String[] args) throws Exception {MapString, Object properties new HashMapString, Object();properties.put(JAXBContextProperties.MEDIA_TYPE, application/json);properties.put(JAXBContextProperties.JSON_INCLUDE_ROOT, false);JAXBContext jc JAXBContext.newInstance(new Class[] {JsonSchema.class}, properties);Unmarshaller unmarshaller jc.createUnmarshaller();StreamSource json new StreamSource(src/blog/variablenode/jsonschema/input.json);JsonSchema jsonSchema unmarshaller.unmarshal(json, JsonSchema.class).getValue();Marshaller marshaller jc.createMarshaller();marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);marshaller.marshal(jsonSchema, System.out);}}外部元数据 MOXy还提供了一个外部映射文档该文档使您可以为第三方对象提供元数据或为模型应用备用映射请参阅将对象映射到多个XML模式–天气示例 。 以下是此示例的映射文档。 ?xml version1.0? xml-bindingsxmlnshttp://www.eclipse.org/eclipselink/xsds/persistence/oxmpackage-nameblog.variablenode.jsonschemaxml-accessor-typeFIELDjava-typesjava-type nameJsonSchemajava-attributesxml-variable-node java-attributeproperties java-variable-attributenamexml-element-wrapper//xml-variable-node/java-attributes/java-typejava-type namePropertyjava-attributesxml-transient java-attributename//java-attributes/java-type/java-types /xml-bindings 参考 来自MOXy的XmlVariableNode –来自我们的JCG合作伙伴 Blaise Doughan的JSON模式示例 位于Java XMLJSON Binding博客上。 翻译自: https://www.javacodegeeks.com/2013/06/moxys-xmlvariablenode-json-schema-example.html
http://www.yutouwan.com/news/369286/

相关文章:

  • 网站开发记什么费用wordpress 后台修改模板
  • 摄影作品网站风景江苏省建设执业网站
  • 网页设计与网站建设报告书住房和城乡建设厅网站
  • 企业网站建设的常见流程网上商城系统流程图
  • 想建设一个网站广告中国
  • 免费开网站系统厦门市网站建设局
  • 如何做好品牌网站建设专业做网站的团队推荐
  • 一个大网站需要多少钱wordpress ios shared
  • 网站首页标题五大常用办公软件
  • 石柱县建设局网站网页设计模板教程
  • 河津北京网站建设wordpress 单栏 主题
  • 为什么网站搜索不到邢台高端网站建设公司
  • 建网站要注册吗软件开发文档用什么写
  • 太原注册公司网站用wordpress做音乐网站
  • saas建站源码下载找人做网站如何担保
  • 如何制作建筑公司网站装修公司做网销的网站
  • 网站备案账户名如何查询在线免费做网站
  • 贴心的合肥网站建设网站注册收入
  • 南通企业建站模板上海手机网站建设公司
  • 做开箱的网站网站使用arial字体下载
  • 建设工程信息哪个网站有详细信息wordpress下一篇
  • 自己搭建网站需要什么产品网站定制
  • 南宁百度网站公司吗折800网站模板
  • 教人做策划的网站企业在什么网站推广
  • 做亚马逊外国网站需要语言好吗怎么下载网站程序
  • 抖音小程序代理郑州网站制作选择乐云seo
  • 在线做试卷的网站17我们一起做网站
  • wordpress整站无刷新网站登录后不显示内容
  • 无锡建设网站wordpress如何重装
  • 高端大气上档次的网站模板网站服务器设置