I have a json array as a string in the following format:
[ "Ford", "BMW", "Fiat" ]
which is a legal json string. How am I able to use Gson to save into an object? When I am trying to use getAsJsonArray(), but I get an error:
java.lang.IllegalStateException: This is not a JSON Array.
JsonArray jArray = new JsonParser().parse(jsonStr).getAsJsonArray();works fine for me. If you got that exception this means that you are not parsing what you expect. Post proper minimal reproducible example (a.k.a. SSCCE)an object. Your question is vague, what object do you want to save it to?