You need to sign in to do that
Don't have an account?

System.JSONException: Malformed JSON: Expected '[' at the beginning of List/Set
Hi,
I've created below class and want to display records in Visual source page.
And my jSon :
{ "data": [ { "name": "dsvsd", "id": "5275838" },
public class JSON2Apex1{
public class Data {
public String name;
public String id;
}
public class Paging {
public String next;
}
public List<Data> data;
public Paging paging;
public static JSON2Apex1 parse(String json) {
return (JSON2Apex1) System.JSON.deserialize(json, JSON2Apex1.class);
}
}
The JSON you posted is indeed malformed. Should have been like this:
{
"data": [
{
"name": "dsvsd",
"id": "5275838"
}
]
}
Ya i have take same format which u have mentioned but same error is getting.
The code given works perfectly fine for me, for the input I posted.
public class Facebook_Login_jSon {
public class Data {
public String name;
public String id;
}
public class Paging {
public String next;
}
public List<Data> data;
public Paging paging;
public static Facebook_Login_jSon parse(String json) {
return (Facebook_Login_jSon) System.JSON.deserialize(json, Facebook_Login_jSon.class);
}
}
here my doubt is how to take data from List<Data>
I'm not sure what you mean here. You should process the list like any other list. Iterate through the list to get the records in it.
[
{
"name": "dsvsd",
"id": "5275838"
}
]
It is taking as
{
"data": [
{
"name": "dsvsd",
"id": "5275838"
}
]
}
Up to my knowledge this part is reason for getting error
{
"data":
}