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

Java JsonSchema类代码示例

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

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



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

示例1: main

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
public static void main(String[] args) throws JsonMappingException {
	ObjectMapper jsonMapper = new ObjectMapper();
    AnnotationIntrospector introspector = new AnnotationIntrospector.Pair(new JaxbAnnotationIntrospector(), 
    		new JacksonAnnotationIntrospector());
    jsonMapper.setAnnotationIntrospector(introspector);
    JsonSchema schema = jsonMapper.generateJsonSchema(Testi.class);
    if(Testi.class.getAnnotation(XmlRootElement.class)!=null
    		&& !Testi.class.getAnnotation(XmlRootElement.class).name().equals("##default"))
    	schema.getSchemaNode().put("name", Testi.class.getAnnotation(XmlRootElement.class).name());
    else if(Testi.class.getAnnotation(XmlType.class)!=null
    		&& !Testi.class.getAnnotation(XmlType.class).name().equals("##default"))
    	schema.getSchemaNode().put("name", Testi.class.getAnnotation(XmlType.class).name());
    else
    	schema.getSchemaNode().put("name", Testi.class.getSimpleName());
    String schemaJson = schema.toString();
	System.out.println(schemaJson);
}
 
开发者ID:sumeetchhetri,项目名称:test-html-generator-plugin,代码行数:18,代码来源:Testi.java


示例2: getSchema

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
    throws JsonMappingException
{
    ObjectNode o = createSchemaNode("array", true);
    if (typeHint != null) {
        JavaType javaType = TypeFactory.type(typeHint);
        if (javaType.isArrayType()) {
            Class<?> componentType = ((ArrayType) javaType).getContentType().getRawClass();
            JsonSerializer<Object> ser = provider.findValueSerializer(componentType);
            JsonNode schemaNode = (ser instanceof SchemaAware) ?
                    ((SchemaAware) ser).getSchema(provider, null) :
                    JsonSchema.getDefaultSchemaNode();
            o.put("items", schemaNode);
        }
    }
    return o;
}
 
开发者ID:r00li,项目名称:RHome,代码行数:18,代码来源:ArraySerializers.java


示例3: getSchema

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
    throws JsonMappingException
{
    ObjectNode o = createSchemaNode("object", true);
    if (typeHint instanceof ParameterizedType) {
        Type[] typeArgs = ((ParameterizedType) typeHint).getActualTypeArguments();
        if (typeArgs.length == 2) {
            JavaType enumType = TypeFactory.type(typeArgs[0]);
            JavaType valueType = TypeFactory.type(typeArgs[1]);
            ObjectNode propsNode = JsonNodeFactory.instance.objectNode();
            Class<Enum<?>> enumClass = (Class<Enum<?>>) enumType.getRawClass();
            for (Enum<?> enumValue : enumClass.getEnumConstants()) {
                JsonSerializer<Object> ser = provider.findValueSerializer(valueType.getRawClass());
                JsonNode schemaNode = (ser instanceof SchemaAware) ?
                        ((SchemaAware) ser).getSchema(provider, null) :
                        JsonSchema.getDefaultSchemaNode();
                propsNode.put(provider.getConfig().getAnnotationIntrospector().findEnumValue((Enum<?>)enumValue), schemaNode);
            }
            o.put("properties", propsNode);
        }
    }
    return o;
}
 
开发者ID:r00li,项目名称:RHome,代码行数:26,代码来源:EnumMapSerializer.java


示例4: DeploymentRequestHandler

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
public DeploymentRequestHandler() {
    m_mapper = new ObjectMapper();
    //Mixin for to not output passwords.
    m_mapper.getSerializationConfig().addMixInAnnotations(UsersType.User.class, IgnorePasswordMixIn.class);
    //We want jackson to stop closing streams
    m_mapper.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
    try {
        JsonSchema schema = m_mapper.generateJsonSchema(DeploymentType.class);
        m_schema = schema.toString();
    } catch (JsonMappingException ex) {
        m_log.warn("Failed to generate JSON schema: ", ex);
    }
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:14,代码来源:HTTPAdminListener.java


示例5: getSchema

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
public JsonNode getSchema(SerializerProvider paramSerializerProvider, Type paramType)
  throws JsonMappingException
{
  if ((this._valueSerializer instanceof SchemaAware))
    return ((SchemaAware)this._valueSerializer).getSchema(paramSerializerProvider, null);
  return JsonSchema.getDefaultSchemaNode();
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:8,代码来源:JsonValueSerializer.java


示例6: getSchema

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
public JsonNode getSchema(SerializerProvider paramSerializerProvider, Type paramType)
  throws JsonMappingException
{
  ObjectNode localObjectNode = createSchemaNode("array", true);
  JavaType localJavaType = null;
  if (paramType != null)
  {
    localJavaType = paramSerializerProvider.constructType(paramType).getContentType();
    if ((localJavaType == null) && ((paramType instanceof ParameterizedType)))
    {
      Type[] arrayOfType = ((ParameterizedType)paramType).getActualTypeArguments();
      if (arrayOfType.length == 1)
        localJavaType = paramSerializerProvider.constructType(arrayOfType[0]);
    }
  }
  if ((localJavaType == null) && (this._elementType != null))
    localJavaType = this._elementType;
  if (localJavaType != null)
  {
    Class localClass = localJavaType.getRawClass();
    JsonNode localJsonNode = null;
    if (localClass != Object.class)
    {
      JsonSerializer localJsonSerializer = paramSerializerProvider.findValueSerializer(localJavaType, this._property);
      boolean bool = localJsonSerializer instanceof SchemaAware;
      localJsonNode = null;
      if (bool)
        localJsonNode = ((SchemaAware)localJsonSerializer).getSchema(paramSerializerProvider, null);
    }
    if (localJsonNode == null)
      localJsonNode = JsonSchema.getDefaultSchemaNode();
    localObjectNode.put("items", localJsonNode);
  }
  return localObjectNode;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:36,代码来源:ContainerSerializers.java


示例7: generateJsonSchema

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
public JsonSchema generateJsonSchema(Class<?> paramClass, SerializationConfig paramSerializationConfig, SerializerFactory paramSerializerFactory)
  throws JsonMappingException
{
  if (paramClass == null)
    throw new IllegalArgumentException("A class must be provided");
  StdSerializerProvider localStdSerializerProvider = createInstance(paramSerializationConfig, paramSerializerFactory);
  if (localStdSerializerProvider.getClass() != getClass())
    throw new IllegalStateException("Broken serializer provider: createInstance returned instance of type " + localStdSerializerProvider.getClass() + "; blueprint of type " + getClass());
  JsonSerializer localJsonSerializer = localStdSerializerProvider.findValueSerializer(paramClass, null);
  if ((localJsonSerializer instanceof SchemaAware));
  for (JsonNode localJsonNode = ((SchemaAware)localJsonSerializer).getSchema(localStdSerializerProvider, null); !(localJsonNode instanceof ObjectNode); localJsonNode = JsonSchema.getDefaultSchemaNode())
    throw new IllegalArgumentException("Class " + paramClass.getName() + " would not be serialized as a JSON object and therefore has no schema");
  return new JsonSchema((ObjectNode)localJsonNode);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:15,代码来源:StdSerializerProvider.java


示例8: getSchema

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
public JsonNode getSchema(SerializerProvider paramSerializerProvider, Type paramType)
  throws JsonMappingException
{
  ObjectNode localObjectNode1 = createSchemaNode("object", true);
  if ((paramType instanceof ParameterizedType))
  {
    Type[] arrayOfType = ((ParameterizedType)paramType).getActualTypeArguments();
    if (arrayOfType.length == 2)
    {
      JavaType localJavaType1 = paramSerializerProvider.constructType(arrayOfType[0]);
      JavaType localJavaType2 = paramSerializerProvider.constructType(arrayOfType[1]);
      ObjectNode localObjectNode2 = JsonNodeFactory.instance.objectNode();
      Enum[] arrayOfEnum = (Enum[])localJavaType1.getRawClass().getEnumConstants();
      int i = arrayOfEnum.length;
      int j = 0;
      if (j < i)
      {
        Enum localEnum = arrayOfEnum[j];
        JsonSerializer localJsonSerializer = paramSerializerProvider.findValueSerializer(localJavaType2.getRawClass(), this._property);
        if ((localJsonSerializer instanceof SchemaAware));
        for (JsonNode localJsonNode = ((SchemaAware)localJsonSerializer).getSchema(paramSerializerProvider, null); ; localJsonNode = JsonSchema.getDefaultSchemaNode())
        {
          localObjectNode2.put(paramSerializerProvider.getConfig().getAnnotationIntrospector().findEnumValue(localEnum), localJsonNode);
          j++;
          break;
        }
      }
      localObjectNode1.put("properties", localObjectNode2);
    }
  }
  return localObjectNode1;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:33,代码来源:EnumMapSerializer.java


示例9: getSchema

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
    throws JsonMappingException
{
    return (_valueSerializer instanceof SchemaAware) ?
            ((SchemaAware) _valueSerializer).getSchema(provider, null) :
            JsonSchema.getDefaultSchemaNode();
}
 
开发者ID:r00li,项目名称:RHome,代码行数:8,代码来源:JsonValueSerializer.java


示例10: getSchema

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
    throws JsonMappingException
{
    /* 15-Jan-2010, tatu: This should probably be rewritten, given that
     *    more information about content type is actually being explicitly
     *    passed. So there should be less need to try to re-process that
     *    information.
     */
    ObjectNode o = createSchemaNode("array", true);
    JavaType contentType = null;
    if (typeHint != null) {
        JavaType javaType = TypeFactory.type(typeHint);
        contentType = javaType.getContentType();
        if (contentType == null) { // could still be parametrized (Iterators)
            if (typeHint instanceof ParameterizedType) {
                Type[] typeArgs = ((ParameterizedType) typeHint).getActualTypeArguments();
                if (typeArgs.length == 1) {
                    contentType = TypeFactory.type(typeArgs[0]);
                }
            }
        }
    }
    if (contentType == null && _elementType != null) {
        contentType = _elementType;
    }
    if (contentType != null) {
        JsonSerializer<Object> ser = provider.findValueSerializer(contentType);
        JsonNode schemaNode = (ser instanceof SchemaAware) ?
                ((SchemaAware) ser).getSchema(provider, null) :
                JsonSchema.getDefaultSchemaNode();
        o.put("items", schemaNode);
    }
    return o;
}
 
开发者ID:r00li,项目名称:RHome,代码行数:36,代码来源:ContainerSerializers.java


示例11: generateJsonSchema

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
@Override
public JsonSchema generateJsonSchema(Class<?> type, SerializationConfig config, SerializerFactory jsf)
        throws JsonMappingException
{
    if (type == null) {
        throw new IllegalArgumentException("A class must be provided.");
    }

    /* First: we need a separate instance, which will hold a copy of the
     * non-shared ("local") read-only lookup Map for fast
     * class-to-serializer lookup
     */
    StdSerializerProvider inst = createInstance(config, jsf);
    // sanity check to avoid weird errors; to ensure sub-classes do override createInstance
    if (inst.getClass() != getClass()) {
        throw new IllegalStateException("Broken serializer provider: createInstance returned instance of type "+inst.getClass()+"; blueprint of type "+getClass());
    }
    /* no need for embedded type information for JSON schema generation (all
     * type information it needs is accessible via "untyped" serializer)
     */
    JsonSerializer<Object> ser = inst.findValueSerializer(type);
    JsonNode schemaNode = (ser instanceof SchemaAware) ?
            ((SchemaAware) ser).getSchema(inst, null) : 
            JsonSchema.getDefaultSchemaNode();
    if (!(schemaNode instanceof ObjectNode)) {
        throw new IllegalArgumentException("Class " + type.getName() +
                " would not be serialized as a JSON object and therefore has no schema.");
    }

    return new JsonSchema((ObjectNode) schemaNode);
}
 
开发者ID:r00li,项目名称:RHome,代码行数:32,代码来源:StdSerializerProvider.java


示例12: getSchema

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
    throws JsonMappingException
{
    ObjectNode o = createSchemaNode("object", true);
    //todo: should the classname go in the title?
    //o.put("title", _className);
    ObjectNode propertiesNode = o.objectNode();
    for (int i = 0; i < _props.length; i++) {
        BeanPropertyWriter prop = _props[i];
        Type hint = prop.getRawSerializationType();
        if (hint == null) {
            hint = prop.getGenericPropertyType();
        }
        // Maybe it already has annotated/statically configured serializer?
        JsonSerializer<Object> ser = prop.getSerializer();
        if (ser == null) { // nope
            Class<?> serType = prop.getRawSerializationType();
            if (serType == null) {
                serType = prop.getPropertyType();
            }
            ser = provider.findValueSerializer(serType);
        }
        JsonNode schemaNode = (ser instanceof SchemaAware) ?
                ((SchemaAware) ser).getSchema(provider, hint) : 
                JsonSchema.getDefaultSchemaNode();
        o.put("items", schemaNode);
        propertiesNode.put(prop.getName(), schemaNode);
    }
    o.put("properties", propertiesNode);
    return o;
}
 
开发者ID:r00li,项目名称:RHome,代码行数:33,代码来源:BeanSerializer.java


示例13: generateSimpleResponse

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
@Test
public void generateSimpleResponse( ) throws JsonMappingException {

    ObjectMapper mapper = new ObjectMapper();
    JsonSchema jsonSchema = mapper.generateJsonSchema(Response.class);
    System.out.println("Response:");
    System.out.println("");
    System.out.println(jsonSchema.toString());
    System.out.println("");
    System.out.println("======================");
}
 
开发者ID:voncuver,项目名称:cwierkacz,代码行数:12,代码来源:Generator.java


示例14: generateLoginResponse

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
@Test
public void generateLoginResponse( ) throws JsonMappingException {

    ObjectMapper mapper = new ObjectMapper();
    JsonSchema jsonSchema = mapper.generateJsonSchema(LoginResponse.class);
    System.out.println("Login Response:");
    System.out.println("");
    System.out.println(jsonSchema.toString());
    System.out.println("");
    System.out.println("======================");
}
 
开发者ID:voncuver,项目名称:cwierkacz,代码行数:12,代码来源:Generator.java


示例15: generateFetchResponse

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
@Test
public void generateFetchResponse( ) throws JsonMappingException {

    ObjectMapper mapper = new ObjectMapper();
    JsonSchema jsonSchema = mapper.generateJsonSchema(FetchMessagesResponse.class);
    System.out.println("Fetch Response:");
    System.out.println("");
    System.out.println(jsonSchema.toString());
    System.out.println("");
    System.out.println("======================");
}
 
开发者ID:voncuver,项目名称:cwierkacz,代码行数:12,代码来源:Generator.java


示例16: generateMessageResponse

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
@Test
public void generateMessageResponse( ) throws JsonMappingException {

    ObjectMapper mapper = new ObjectMapper();
    JsonSchema jsonSchema = mapper.generateJsonSchema(Message.class);
    System.out.println("Message:");
    System.out.println("");
    System.out.println(jsonSchema.toString());
    System.out.println("");
    System.out.println("======================");
}
 
开发者ID:voncuver,项目名称:cwierkacz,代码行数:12,代码来源:Generator.java


示例17: generateAccountResponse

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
@Test
public void generateAccountResponse( ) throws JsonMappingException {

    ObjectMapper mapper = new ObjectMapper();
    JsonSchema jsonSchema = mapper.generateJsonSchema(Account.class);
    System.out.println("Account:");
    System.out.println("");
    System.out.println(jsonSchema.toString());
    System.out.println("");
    System.out.println("======================");
}
 
开发者ID:voncuver,项目名称:cwierkacz,代码行数:12,代码来源:Generator.java


示例18: getSchema

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
    throws JsonMappingException
{
    ObjectNode o = createSchemaNode("object", true);
    //todo: should the classname go in the title?
    //o.put("title", _className);
    ObjectNode propertiesNode = o.objectNode();
    for (int i = 0; i < _props.length; i++) {
        BeanPropertyWriter prop = _props[i];
        JavaType propType = prop.getSerializationType();
        // 03-Dec-2010, tatu: SchemaAware REALLY should use JavaType, but alas it doesn't...
        Type hint = (propType == null) ? prop.getGenericPropertyType() : propType.getRawClass();
        // Maybe it already has annotated/statically configured serializer?
        JsonSerializer<Object> ser = prop.getSerializer();
        if (ser == null) { // nope
            Class<?> serType = prop.getRawSerializationType();
            if (serType == null) {
                serType = prop.getPropertyType();
            }
            ser = provider.findValueSerializer(serType, prop);
        }
        JsonNode schemaNode = (ser instanceof SchemaAware) ?
                ((SchemaAware) ser).getSchema(provider, hint) : 
                JsonSchema.getDefaultSchemaNode();
        if(prop.getAnnotation(XmlAttribute.class)!=null && schemaNode instanceof ObjectNode)
        	((ObjectNode)schemaNode).put("isattr", true);
        propertiesNode.put(prop.getName(), schemaNode);
    }
    o.put("properties", propertiesNode);
    if(typeHint instanceof Class)
    {
    	Class<?> claz = (Class<?>)typeHint;
     if(claz.getAnnotation(XmlRootElement.class)!=null
     		&& !claz.getAnnotation(XmlRootElement.class).name().equals("##default"))
     	o.put("name", claz.getAnnotation(XmlRootElement.class).name());
     else if(claz.getAnnotation(XmlType.class)!=null
     		&& !claz.getAnnotation(XmlType.class).name().equals("##default"))
     	o.put("name", claz.getAnnotation(XmlType.class).name());
     else
     	o.put("name", claz.getSimpleName());
    }
    return o;
}
 
开发者ID:sumeetchhetri,项目名称:test-html-generator-plugin,代码行数:45,代码来源:BeanSerializerBase.java


示例19: generateJsonSchema

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
public JsonSchema generateJsonSchema(Class<?> paramClass)
  throws JsonMappingException
{
  return generateJsonSchema(paramClass, copySerializationConfig());
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:6,代码来源:ObjectMapper.java


示例20: generateJsonSchema

import org.codehaus.jackson.schema.JsonSchema; //导入依赖的package包/类
public abstract JsonSchema generateJsonSchema(Class<?> paramClass, SerializationConfig paramSerializationConfig, SerializerFactory paramSerializerFactory)
throws JsonMappingException;
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:3,代码来源:SerializerProvider.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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