I'm trying to serialize a list of BasicNameValuePairs using type adapters and Gson
ArrayList<BasicNameValuePair> kvp=new ArrayList<BasicNameValuePair>();
kvp.add(new BasicNameValuePair("car","ferrari"));
kvp.add(new BasicNameValuePair("speed","fast"));
this is the result I want
{"car":"ferrari","speed":"fast"}
instead of this
[{"name":"car","value":"ferrari"},{"name":"speed","value":"fast"}]
To serialize this according to specification you need to make a custom type adapter that will handle the generic list. First create the class that will do the proper formatting on the output.
Then use a custom Gson builder to use that type adapter to create the proper JSON string.