My Json Array looks like this
[
{
"geoRegion":"101",
"companyName":"101",
"department":"101",
"industry":"101",
"sector":"101",
"formName":"101",
"formType":true,
"fields":[
{
"labelId":"102",
"bizJust":"101"
},
{
"labelId":"103",
"bizJust":"101"
},
{
"labelId":"104",
"bizJust":"101"
},
{
"labelId":"129",
"bizJust":"102"
},
{
"labelId":"128",
"bizJust":"102"
},
{
"labelId":"144",
"bizJust":"102"
},
{
"labelId":"143",
"bizJust":"102"
}
]
}
]
My code is as following:
public Map<String,String> createTransaction(String lang) throws Exception {
Gson gson =new Gson();
JsonObject jsonObj=gson.fromJson(lang, JsonObject.class);//Exception thrown at this line
}
JsonArraywhen it's an array, and to aJsonObjectwhen it's an object.