Package cc.plural.jsonij

Examples of cc.plural.jsonij.Value


        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
        return marshaledArray;
    }

    public static Value marshalObjectToValue(float[] a) {
        Value marshaledArray = JAVA_MARSHALLER.marshalObject(a);
        return marshaledArray;
    }
View Full Code Here


        innerObjectAttribute = "_innerObject";
    }

    public Object marshalJSONDocument(JSON json, Class<?> objectClass) throws JSONMarshalerException {
        Object resultObject = null;
        Value jsonRoot = json.getRoot();
        if (jsonRoot.type() == Value.TYPE.OBJECT) {
            JSON.Object<CharSequence, Value> jsonObjectRoot = (JSON.Object<CharSequence, Value>) jsonRoot;
            resultObject = marshalJSONDocumentObject(jsonObjectRoot, objectClass);
        } else if (jsonRoot.type() == Value.TYPE.ARRAY) {
            JSON.Array<Value> jsonArrayRoot = (JSON.Array<Value>) jsonRoot;
            resultObject = marshalJSONDocumentArray(jsonArrayRoot, objectClass);
        } else {
            //throw new Exception();
        }
View Full Code Here

        }
        // Check for JSONCodec
        if (codecStore != null && codecStore.hasCodec(objectClass)) {
            @SuppressWarnings("rawtypes")
      JSONCodec codec = codecStore.getCodec(objectClass);
            @SuppressWarnings("unchecked")
      Value value = codec.encode(o);
            return value;
        }

        // Find an object inspector
        Inspector inspector = JavaType.getInstpector(objectClass);

        HashMap<String, Value> valueCollector = new HashMap<String, Value>();
        InspectorProperty[] properties = inspector.getProperties();
        String name = null;
        Value value = null;
        int propCount = 0;
        for (InspectorProperty property : properties) {
            if (!property.hasAccessor()) {
                continue;
            }
View Full Code Here

            return marshaledObject;
        }
    }

    protected Value marshalObjectMethodValue(Method method, Object o, CycleDetector cycleDetector) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
        Value value = null;
        Object marshaledObject = method.invoke(o);
        if (marshaledObject == null) {
            value = null;
        } else {
            int hashCode = marshaledObject.hashCode();
View Full Code Here

        }
        return value;
    }

    protected Value marshalObjectFieldValue(Field field, Object o, CycleDetector cycleDetector) throws IllegalArgumentException, IllegalAccessException {
        Value value = null;
        Object marshaledObject = field.get(o);
        if (marshaledObject == null) {
            value = null;
        } else {
            int hashCode = marshaledObject.hashCode();
View Full Code Here

            return new JSON.Array<JSON.Numeric>();
        }
        CycleDetector cycleDetector = new CycleDetector();
        JSON.Array<Value> marshaledArray = new JSON.Array<Value>();
        for (int i = 0; i < size; i++) {
            Value marshaledObject = marshalJavaObject(a[i], cycleDetector);
            if(marshaledObject != null) {
                marshaledArray.add(marshaledObject);
            } else {
                marshaledArray.add(JSON.NULL);
            }
View Full Code Here

    protected Value marshalAnyObject(Object o, CycleDetector cycleDetector) {
        if(o == null) {
            return JSON.NULL;
        }
        Value marshaledObject = null;
        Class<?> objectClass = o.getClass();
        JavaType objectType = JavaType.inspectObjectType(objectClass);
        switch (objectType) {
            case BOOLEAN:
                marshaledObject = marshalJavaBoolean(o);
View Full Code Here

        }
        return marshaledObject;
    }

    protected Value marshalJavaBoolean(Object o) {
        Value value = null;
        boolean marshaledBoolean = (Boolean) o;
        if (marshaledBoolean) {
            value = JSON.TRUE;
        } else {
            value = JSON.FALSE;
View Full Code Here

        }
        return value;
    }

    protected Value marshalJavaNumeric(Object o) {
        Value value = null;
        Number marshaledNumber = null;
        marshaledNumber = (Number) o;
        if (marshaledNumber != null) {
            value = new JSON.Numeric(marshaledNumber);
        } else {
View Full Code Here

        }
        return value;
    }

    protected Value marshalJavaEnum(Object o) {
        Value value = null;
        if (o != null) {
            String marshaledEnumeration = o.toString();
            value = new JSON.String(marshaledEnumeration);
        } else {
            value = JSON.NULL;
View Full Code Here

TOP

Related Classes of cc.plural.jsonij.Value

Copyright © 2018 www.massapicom. 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.