-1

I have the following configuration :

  <property name="defaultViews">
            <list>
                <!-- JSON View -->
                <bean    class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
                <!-- XML View -->
                <bean class="org.springframework.web.servlet.view.xml.MarshallingView">
                    <constructor-arg>
                        <bean class="org.springframework.oxm.xstream.XStreamMarshaller">
                            <property name="autodetectAnnotations" value="true" />
                        </bean>
                    </constructor-arg>
                </bean>
            </list>
        </property>

It creates a json, but the root name is not what i want

@XStreamAlias("house")
@JsonAutoDetect
@JsonRootName(value = "house")  
public class TableHouse {

    private Long value;

.....
}

For the xml it works fine, however for the json it does not pick up the @JsonRootName.. and outputs json with class name as root...

Any ideas?

user1555190
  • 2,803
  • 8
  • 47
  • 80

1 Answers1

0

You have to enable root-level wrapping. See How do I rename the root key of a JSON with Java Jackson? to have an idea on how to use JsonRootName properly.

Community
  • 1
  • 1
ramirezag
  • 554
  • 5
  • 9