How to remove field values from java to gson().tojson
my json output displays field name in my json array.
[name:jimmy,surname:hat]
what do i need to do to return in this format with just the values开发者_C百科.
[jimmy,hat]
Typically if you have an array in your code, something like this:
class X {
String[] y = new String[] { "a", "b", "c" }
}
Gson converts to:
{
"y":["a","b","c"]
}
If your array is holding objects, i.e.
class Y {
String name;
String val;
}
class X {
Y[] y; // some data
}
Gson converts to:
{
"y":[{"name":"n1","val":"v1"},{"name":"n2","val":"v2"}]
}
So, if you want your array to be only values, just be sure it's an array of strings.
精彩评论