search

Home  >  Q&A  >  body text

java 对象转json字符串忽略类型,所有值都加上双引号,如何做?我用的是fastjson。

  1. 例如
    我一个对象转成json后是这样

[{"desc":"data","type":1,"name":"data"}]
我想转成这样
[{"desc":"data","type":"1","name":"data"}]
type是int类型

巴扎黑巴扎黑2769 days ago949

reply all(2)I'll reply

  • PHPz

    PHPz2017-04-18 10:32:05

    The standard data format of JSON is that numeric types do not require double quotes, unless your data type is a string. .

    reply
    0
  • PHPz

    PHPz2017-04-18 10:32:05

    JSON.toJSONString(json, SerializerFeature.WriteNonStringValueAsString)

    reply
    0
  • Cancelreply