문제

In general, jackson is serialize beans to standard json format, for example, the following class:

public class Person {
    private String name;
    private int age;
    // getter/setter
}

will serialize to following json:

{
  "name" : "test1111",
  "age" : 18
}

but i want to get the format like this(non-standard):

{
  name : test1111,
  age : 18
}

that is to say, i didn't want to output the double-quote despite of the type. Thanks for help in advance!

도움이 되었습니까?

해결책

That is not valid JSON and therefore you cannot use Jackson to generate it.

If you want, you can use Jackson to generate a String value of

{
  "name" : "test1111",
  "age" : 18
}

and then manually remove the quotes.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top