public static JsonElement wrap ( Object o ) throws JsonException { if ( o == null ) { //null value means not specified i.e.-> no valued will be mapped //Json.null is specific value return null ; } if ( o instanceof JsonElement ) { return ( JsonElement ) o ; } if ( o instanceof ElementWrapper ) { return ( ( ElementWrapper ) o ) . getJson ( ) ; } if ( o instanceof Collection ) { return new JsonArray ( ( Collection ) o ) ; } else if ( o . getClass ( ) . isArray ( ) ) { return new JsonArray ( o ) ; } if ( o instanceof Map ) { return new JsonObject ( ( Map ) o ) ; } if ( o instanceof Boolean ) { return new JsonBoolean ( ( Boolean ) o ) ; } if ( o instanceof Number ) { return new JsonNumber ( ( Number ) o ) ; } if ( o instanceof String ) { return new JsonString ( ( String ) o ) ; } if ( o instanceof Character ) { return new JsonString ( Character . toString ( ( Character ) o ) ) ; } if ( o instanceof ByteBuffer ) { return new JsonString ( ( ( ByteBuffer ) o ) . asCharBuffer ( ) . toString ( ) ) ; } return new JsonString ( o . toString ( ) ) ; }
Wraps the given object if to JsonXXX object .