I'm using PHP to return a JSON encoded associative array to a client. The array is constructed by looping through the result set of a MySQL database query. For simplicity's sake, instead of showing all the code that returns the result set, let's say that one possible output to the query produces the following associative array in PHP:
$ResultRows = array(
"10 m" => 10,
"100 m" => 100,
"1000 m" => 1000
);
echo json_encode($ResultRows);
The JSON string produced by json_encode looks like this:
{"10 m":10,"100 m":100,"1000 m":1000}
As you can see, it gets encoded like an object with each key-value pair looking like a property name and value.
Now, the client running Java receives this JSON encoded string. I would like to create an instance of LinkedHashMap<String, Double> that is populated by these values. However, since it is not encoded like an array, I'm having a hard time seeing how to use GSON to decode this. Any ideas?
I could simply change the PHP and create a simple object that holds the Key/Value pairs and return a regular array of these objects, but I was hoping to leave the PHP scripts alone if possible because there are quite a few of them to change.