I get this exception:
java.lang.Exception: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 3 path $[0]
when tring to parse this json:
[
"[{\"IdProduit\":1,\"NumeroSerie\":\"1234579657\",\"NomProduit\":\"Puce BigKing\",\"Prix\":200.0,\"Quantite\":500,\"IdModel\":1,\"IdModelNavigation\":{\"IdModel\":1,\"NomModel\":\"Puces\",\"Produit\":[],\"StockModel\":[]}},{\"IdProduit\":2,\"NumeroSerie\":\"12345687\",\"NomProduit\":\"Puce La Win\",\"Prix\":2000.0,\"Quantite\":60,\"IdModel\":1,\"IdModelNavigation\":{\"IdModel\":1,\"NomModel\":\"Puces\",\"Produit\":[],\"StockModel\":[]}},{\"IdProduit\":3,\"NumeroSerie\":\"124576328\",\"NomProduit\":\"Carte De Recharge 200DA\",\"Prix\":200.0,\"Quantite\":300,\"IdModel\":2,\"IdModelNavigation\":{\"IdModel\":2,\"NomModel\":\"Carte De Recharge\",\"Produit\":[],\"StockModel\":[]}}]"
]
You need to add your POJO structure to the question to make it clear. But maybe you need to remove the " inside your first json array.
So it will look like this
[
[
{
"IdProduit":1,
"NumeroSerie":"1234579657",
"NomProduit":"Puce BigKing",
"Prix":200.0,
"Quantite":500,
"IdModel":1,
"IdModelNavigation":{
"IdModel":1,
"NomModel":"Puces",
"Produit":[
],
"StockModel":[
]
}
},
{
"IdProduit":2,
"NumeroSerie":"12345687",
"NomProduit":"Puce La Win",
"Prix":2000.0,
"Quantite":60,
"IdModel":1,
"IdModelNavigation":{
"IdModel":1,
"NomModel":"Puces",
"Produit":[
],
"StockModel":[
]
}
},
{
"IdProduit":3,
"NumeroSerie":"124576328",
"NomProduit":"Carte De Recharge 200DA",
"Prix":200.0,
"Quantite":300,
"IdModel":2,
"IdModelNavigation":{
"IdModel":2,
"NomModel":"Carte De Recharge",
"Produit":[
],
"StockModel":[
]
}
}
]
]
Or if you are using string literal in Java you need to add \ before ". If this does not solve your problem please edit your question with your POJO
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.