Package org.codehaus.groovy.grails.web.json

Examples of org.codehaus.groovy.grails.web.json.JSONWriter.key()


        Errors errors = (Errors) object;
        JSONWriter writer = json.getWriter();

        try {
            writer.object();
            writer.key("errors");
            writer.array();

            for (Object o : errors.getAllErrors()) {
                if (o instanceof FieldError) {
                    FieldError fe = (FieldError) o;
View Full Code Here


        BeanWrapper beanWrapper = new BeanWrapperImpl(value);

        writer.object();

        if(shouldInclude(includeExcludeSupport, includes, excludes, value, "class")) {
            writer.key("class").value(domainClass.getClazz().getName());
        }


        GrailsDomainClassProperty id = domainClass.getIdentifier();
View Full Code Here

        GrailsDomainClassProperty[] properties = domainClass.getPersistentProperties();

        for (GrailsDomainClassProperty property : properties) {
            if(!shouldInclude(includeExcludeSupport, includes, excludes, value, property.getName())) continue;

            writer.key(property.getName());
            if (!property.isAssociation()) {
                // Write non-relation property
                Object val = beanWrapper.getPropertyValue(property.getName());
                json.convertAnother(val);
            }
View Full Code Here

                                Map<Object, Object> map = (Map<Object, Object>) referenceObject;
                                for (Map.Entry<Object, Object> entry : map.entrySet()) {
                                    String key = String.valueOf(entry.getKey());
                                    Object o = entry.getValue();
                                    writer.object();
                                    writer.key(key);
                                    asShortObject(o, json, referencedIdProperty, referencedDomainClass);
                                    writer.endObject();
                                }
                            }
                        }
View Full Code Here

        else {
            idValue = extractValue(refObj, idProperty);
        }
        JSONWriter writer = json.getWriter();
        writer.object();
        writer.key("class").value(referencedDomainClass.getFullName());
        writer.key("id").value(idValue);
        writer.endObject();
    }

    protected Object extractValue(Object domainObject, GrailsDomainClassProperty property) {
View Full Code Here

            idValue = extractValue(refObj, idProperty);
        }
        JSONWriter writer = json.getWriter();
        writer.object();
        writer.key("class").value(referencedDomainClass.getFullName());
        writer.key("id").value(idValue);
        writer.endObject();
    }

    protected Object extractValue(Object domainObject, GrailsDomainClassProperty property) {
        if(domainObject instanceof GroovyObject) {
View Full Code Here

        writer.object();
        Map<Object,Object> map = (Map<Object,Object>) o;
        for (Map.Entry<Object,Object> entry : map.entrySet()) {
            Object key = entry.getKey();
            if (key != null) {
                writer.key(key.toString());
                converter.convertAnother(entry.getValue());
            }
        }
        writer.endObject();
    }
View Full Code Here

                if (readMethod != null && !(name.equals("metaClass"))&& !(name.equals("class"))) {
                    if(readMethod.getAnnotation(PersistenceMethod.class) != null) continue;
                    if(readMethod.getAnnotation(ControllerMethod.class) != null) continue;
                    Object value = readMethod.invoke(o, (Object[]) null);
                    writer.key(name);
                    json.convertAnother(value);
                }
            }
            for (Field field : clazz.getDeclaredFields()) {
                int modifiers = field.getModifiers();
View Full Code Here

            for (Field field : clazz.getDeclaredFields()) {
                int modifiers = field.getModifiers();
                if (Modifier.isPublic(modifiers) && !(Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers))) {
                    String name = field.getName();
                    if(!shouldInclude(includeExcludeSupport,includes,excludes,o,name)) continue;
                    writer.key(name);
                    json.convertAnother(field.get(o));
                }
            }
            writer.endObject();
        }
View Full Code Here

            for (PropertyDescriptor property : BeanUtils.getPropertyDescriptors(o.getClass())) {
                String name = property.getName();
                Method readMethod = property.getReadMethod();
                if (readMethod != null) {
                    Object value = readMethod.invoke(o, (Object[]) null);
                    writer.key(name);
                    json.convertAnother(value);
                }
            }
            for (Field field : o.getClass().getDeclaredFields()) {
                int modifiers = field.getModifiers();
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.