org.eclipse.jetty.util.ajax.JSON.addConvertorFor()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中org.eclipse.jetty.util.ajax.JSON.addConvertorFor()方法的一些代码示例,展示了JSON.addConvertorFor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSON.addConvertorFor()方法的具体详情如下:
包路径:org.eclipse.jetty.util.ajax.JSON
类名称:JSON
方法名:addConvertorFor

JSON.addConvertorFor介绍

[英]Register a JSON.Convertor for a named class or interface.
[中]注册一个JSON。命名类或接口的转换器。

代码示例

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

public void toJSON(Object obj, Output out)
{
  String clsName=obj.getClass().getName();
  Convertor convertor=_json.getConvertorFor(clsName);
  if (convertor==null)
  {
    try
    {
      Class cls=Loader.loadClass(JSON.class,clsName);
      convertor=new JSONPojoConvertor(cls,_fromJson);
      _json.addConvertorFor(clsName, convertor);
     }
    catch (ClassNotFoundException e)
    {
      JSON.LOG.warn(e);
    }
  }
  if (convertor!=null)
  {
    convertor.toJSON(obj, out);
  }
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-webapp

public void toJSON(Object obj, Output out)
{
  String clsName=obj.getClass().getName();
  Convertor convertor=_json.getConvertorFor(clsName);
  if (convertor==null)
  {
    try
    {
      Class cls=Loader.loadClass(JSON.class,clsName);
      convertor=new JSONPojoConvertor(cls,_fromJson);
      _json.addConvertorFor(clsName, convertor);
     }
    catch (ClassNotFoundException e)
    {
      JSON.LOG.warn(e);
    }
  }
  if (convertor!=null)
  {
    convertor.toJSON(obj, out);
  }
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-plus

public void toJSON(Object obj, Output out)
{
  String clsName=obj.getClass().getName();
  Convertor convertor=_json.getConvertorFor(clsName);
  if (convertor==null)
  {
    try
    {
      Class cls=Loader.loadClass(JSON.class,clsName);
      convertor=new JSONPojoConvertor(cls,_fromJson);
      _json.addConvertorFor(clsName, convertor);
     }
    catch (ClassNotFoundException e)
    {
      JSON.LOG.warn(e);
    }
  }
  if (convertor!=null)
  {
    convertor.toJSON(obj, out);
  }
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-server

public void toJSON(Object obj, Output out)
{
  String clsName=obj.getClass().getName();
  Convertor convertor=_json.getConvertorFor(clsName);
  if (convertor==null)
  {
    try
    {
      Class cls=Loader.loadClass(JSON.class,clsName);
      convertor=new JSONPojoConvertor(cls,_fromJson);
      _json.addConvertorFor(clsName, convertor);
     }
    catch (ClassNotFoundException e)
    {
      JSON.LOG.warn(e);
    }
  }
  if (convertor!=null)
  {
    convertor.toJSON(obj, out);
  }
}

代码示例来源:origin: org.eclipse.jetty/jetty-util-ajax

@Override
public void toJSON(Object obj, Output out)
{
  String clsName=obj.getClass().getName();
  Convertor convertor=_json.getConvertorFor(clsName);
  if (convertor==null)
  {
    try
    {
      Class cls=Loader.loadClass(clsName);
      convertor=new JSONPojoConvertor(cls,_fromJson);
      _json.addConvertorFor(clsName, convertor);
     }
    catch (ClassNotFoundException e)
    {
      JSON.LOG.warn(e);
    }
  }
  if (convertor!=null)
  {
    convertor.toJSON(obj, out);
  }
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

public Object fromJSON(Map object)
  {
    Map map=object;
    String clsName=(String)map.get("class");
    if (clsName!=null)
    {
      Convertor convertor=_json.getConvertorFor(clsName);
      if (convertor==null)
      {
        try
        {
          Class cls=Loader.loadClass(JSON.class,clsName);
          convertor=new JSONPojoConvertor(cls,_fromJson);
          _json.addConvertorFor(clsName, convertor);
        }
        catch (ClassNotFoundException e)
        {
          JSON.LOG.warn(e);
        }
      }
      if (convertor!=null)
      {
        return convertor.fromJSON(object);
      }
    }
    return map;
  }
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-server

public Object fromJSON(Map object)
  {
    Map map=object;
    String clsName=(String)map.get("class");
    if (clsName!=null)
    {
      Convertor convertor=_json.getConvertorFor(clsName);
      if (convertor==null)
      {
        try
        {
          Class cls=Loader.loadClass(JSON.class,clsName);
          convertor=new JSONPojoConvertor(cls,_fromJson);
          _json.addConvertorFor(clsName, convertor);
        }
        catch (ClassNotFoundException e)
        {
          JSON.LOG.warn(e);
        }
      }
      if (convertor!=null)
      {
        return convertor.fromJSON(object);
      }
    }
    return map;
  }
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-plus

public Object fromJSON(Map object)
  {
    Map map=object;
    String clsName=(String)map.get("class");
    if (clsName!=null)
    {
      Convertor convertor=_json.getConvertorFor(clsName);
      if (convertor==null)
      {
        try
        {
          Class cls=Loader.loadClass(JSON.class,clsName);
          convertor=new JSONPojoConvertor(cls,_fromJson);
          _json.addConvertorFor(clsName, convertor);
        }
        catch (ClassNotFoundException e)
        {
          JSON.LOG.warn(e);
        }
      }
      if (convertor!=null)
      {
        return convertor.fromJSON(object);
      }
    }
    return map;
  }
}

代码示例来源:origin: org.eclipse.jetty/jetty-util-ajax

@Override
  public Object fromJSON(Map object)
  {
    Map map=object;
    String clsName=(String)map.get("class");
    if (clsName!=null)
    {
      Convertor convertor=_json.getConvertorFor(clsName);
      if (convertor==null)
      {
        try
        {
          Class cls=Loader.loadClass(clsName);
          convertor=new JSONPojoConvertor(cls,_fromJson);
          _json.addConvertorFor(clsName, convertor);
        }
        catch (ClassNotFoundException e)
        {
          JSON.LOG.warn(e);
        }
      }
      if (convertor!=null)
      {
        return convertor.fromJSON(object);
      }
    }
    return map;
  }
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-webapp

public Object fromJSON(Map object)
  {
    Map map=object;
    String clsName=(String)map.get("class");
    if (clsName!=null)
    {
      Convertor convertor=_json.getConvertorFor(clsName);
      if (convertor==null)
      {
        try
        {
          Class cls=Loader.loadClass(JSON.class,clsName);
          convertor=new JSONPojoConvertor(cls,_fromJson);
          _json.addConvertorFor(clsName, convertor);
        }
        catch (ClassNotFoundException e)
        {
          JSON.LOG.warn(e);
        }
      }
      if (convertor!=null)
      {
        return convertor.fromJSON(object);
      }
    }
    return map;
  }
}

相关文章