Examples of JsonSerializationException


Examples of com.browseengine.bobo.serialize.JSONSerializable.JSONSerializationException

      }
      else if (type==Byte.TYPE){
        Array.setByte(array, index, (byte)jsonArray.getInt(index));
      }
      else{
        throw new JSONSerializationException("Unknown primitive: "+type);
      }
    }
    else if (type==String.class){
      Array.set(array, index, jsonArray.getString(index));
    }
View Full Code Here

Examples of com.browseengine.bobo.serialize.JSONSerializable.JSONSerializationException

        }
        else if (type==Byte.TYPE){
          f.setByte(retObj, (byte)jsonObj.getInt(key));
        }
        else{
          throw new JSONSerializationException("Unknown primitive: "+type);
        }
      }
      else if (type==String.class){
        f.set(retObj, jsonObj.getString(key));
      }
      else if (JSONSerializable.class.isAssignableFrom(type)){
        JSONObject jObj=jsonObj.getJSONObject(key);
        JSONSerializable serObj=deSerialize(type,jObj);
        f.set(retObj, serObj);
      }
    }
    catch(Exception e){
      throw new JSONSerializationException(e.getMessage(),e);
    }
  }
View Full Code Here

Examples of com.browseengine.bobo.serialize.JSONSerializable.JSONSerializationException

 
  public static JSONSerializable deSerialize(Class clz,JSONObject jsonObj) throws JSONSerializationException,JSONException{
    Iterator iter=jsonObj.keys();
   
    if (!JSONSerializable.class.isAssignableFrom(clz)){
      throw new JSONSerializationException(clz+" is not an instance of "+JSONSerializable.class);
    }
   
    JSONSerializable retObj;
    try {
      retObj = (JSONSerializable)clz.newInstance();
    } catch (Exception e1) {
      throw new JSONSerializationException("trouble with no-arg instantiation of "+clz.toString()+
          ": "+e1.getMessage(),e1);
    }
   
    if (JSONExternalizable.class.isAssignableFrom(clz)){
      ((JSONExternalizable)retObj).fromJSON(jsonObj);
      return retObj;
    }
   
   
    while(iter.hasNext()){
      String key=(String)iter.next();

      try {
        Field f=clz.getDeclaredField(key);
        if (f!=null){
          f.setAccessible(true);
          Class type=f.getType();
         
          if (type.isArray()){
            JSONArray array=jsonObj.getJSONArray(key);
            int len=array.length();
            Class cls=type.getComponentType();
           
            Object newArray=Array.newInstance(cls, len);
            for (int k=0;k<len;++k){
              loadObject(newArray,cls,k,array);
            }
            f.set(retObj, newArray);
          }
          else{
            loadObject(retObj,f,jsonObj);
          }
        }
      } catch (Exception e) {
        throw new JSONSerializationException(e.getMessage(),e);
      }
    }
   
    return retObj;
  }
View Full Code Here

Examples of com.browseengine.bobo.serialize.JSONSerializable.JSONSerializationException

  private static void dumpObject(JSONObject jsonObj,Field f,JSONSerializable srcObj) throws JSONSerializationException,JSONException{
    Object value;
    try {
      value = f.get(srcObj);
    } catch (Exception e) {
      throw new JSONSerializationException(e.getMessage(),e);
    }
   
    Class type=f.getType();
   
    String name=f.getName();
View Full Code Here

Examples of com.browseengine.bobo.serialize.JSONSerializable.JSONSerializationException

          }
          else{
            dumpObject(jsonObj,fields[i],obj);
          }
        } catch (Exception e) {
          throw new JSONSerializationException(e.getMessage(),e);
        }
      }
    }
   
    return jsonObj;
View Full Code Here

Examples of com.github.nmorel.gwtjackson.client.exception.JsonSerializationException

            @Override
            public String write( T input ) {
                try {
                    return objectMapper.writeValueAsString( input );
                } catch ( JsonProcessingException e ) {
                    throw new JsonSerializationException( e );
                }
            }
        };
    }
View Full Code Here

Examples of com.github.nmorel.gwtjackson.client.exception.JsonSerializationException

            @Override
            public String write( T input ) {
                try {
                    return objectMapper.writeValueAsString( input );
                } catch ( JsonProcessingException e ) {
                    throw new JsonSerializationException( e );
                }
            }
        };
    }
View Full Code Here

Examples of com.github.nmorel.gwtjackson.client.exception.JsonSerializationException

     *
     * @return a {@link JsonSerializationException} with the given message
     */
    public JsonSerializationException traceError( Object value, String message ) {
        getLogger().log( Level.SEVERE, message );
        return new JsonSerializationException( message );
    }
View Full Code Here

Examples of com.github.nmorel.gwtjackson.client.exception.JsonSerializationException

     * @param writer current writer
     *
     * @return a {@link JsonSerializationException} with the given message
     */
    public JsonSerializationException traceError( Object value, String message, JsonWriter writer ) {
        JsonSerializationException exception = traceError( value, message );
        traceWriterInfo( value, writer );
        return exception;
    }
View Full Code Here

Examples of com.github.nmorel.gwtjackson.client.exception.JsonSerializationException

     * @return a {@link JsonSerializationException} if we wrap the exceptions, the cause otherwise
     */
    public RuntimeException traceError( Object value, RuntimeException cause ) {
        getLogger().log( Level.SEVERE, "Error during serialization", cause );
        if ( wrapExceptions ) {
            return new JsonSerializationException( cause );
        } else {
            return cause;
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.