When using Gson to serialize an array to json, I get a new line after each element, e.g.
"values": [
962,
962,
0,
962,
483,
479
]
is there anyway to avoid this, and have all values in the same line within Gson (that is, not post-processing Gson’s output)?
The GsonBuilder should by default compact the data when serializing to JSON. It is possible to configure it to not do this (for readability).
Example for compacting serializer
and for not compacting (pretty print)
See also Gson doc.