I get the data from the web server as json, but I can't deserialize them and access the keys (eg first_name)
The information is received in the client, but Unfortunately, this code does not print anything in the Unity console
my code :
socket.On("UserList", response =>
{
var result = JsonConvert.DeserializeObject<List<UserClass>>(response.ToString());
var first_name = result[0].first_name;
print(first_name);
});
UserClass :
public class UserClass
{
public string _id { get; set; }
public string first_name { get; set; }
public string last_name { get; set; }
public string mobile { get; set; }
public string email { get; set; }
public DateTime createdAt { get; set; }
public DateTime updateAt { get; set; }
public int __v { get; set; }
}
Json that is received in the client :
[
{
"_id": "83ca7d56cbc2b281wd4ee658",
"first_name": "sara",
"last_name": "Paulson",
"mobile": "09323456789",
"email": "sara#gmail.com",
"createdAt": "2023-01-20T12:46:38.384Z",
"updateAt": "2023-01-20T12:46:38.384Z",
"__v": 0
},
{
"_id": "59e41dku510239e83ed7e10m",
"first_name": "Evan",
"last_name": "Peters",
"mobile": "09327931248",
"email": "Evan#gmail.com",
"createdAt": "2023-02-10T10:35:26.687Z",
"updateAt": "2023-02-10T10:35:26.687Z",
"__v": 0
},
{
"_id": "64lm96c57a8a4f289fw0gg66",
"first_name": "Emma",
"last_name": "Roberts",
"mobile": "09325354769",
"email": "Emma#gmail.com",
"createdAt": "2023-01-20T13:11:46.402Z",
"updateAt": "2023-01-20T13:11:46.402Z",
"__v": 0
}
]
How can I access keys of this Json in Unity?
I checked and found that even specifying arrays in JSON works somehow:
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
class UserClass
{
public string _id { get; set; }
public string first_name { get; set; }
public string last_name { get; set; }
public string mobile { get; set; }
public string email { get; set; }
public DateTime createdAt { get; set; }
public DateTime updateAt { get; set; }
public int __v { get; set; }
}
class UserList
{
public List<UserClass> objs;
}
public class Program
{
public static void Main(string[] args)
{
string response = "{'objs': [{'_id': 1, 'first_name': 'abc'}, {'_id': 2, 'first_name': 'def'}]}";
var result = JsonConvert.DeserializeObject<UserList>(response);
if (result != null)
{
foreach (UserClass u in result.objs)
{
Console.Write(u._id + ',');
Console.WriteLine(u.first_name);
}
}
string response2 = "[{'_id': 1, 'first_name': 'abc'}, {'_id': 2, 'first_name': 'def'}]";
var result2 = JsonConvert.DeserializeObject<List<UserClass>>(response2);
if (result2 != null)
{
for (var i = 0; i < result2.Count; i++)
{
Console.Write(result2[i]._id + ',');
Console.WriteLine(result2[i].first_name);
}
}
}
}
Both ways give same output. https://dotnetfiddle.net/g2Dn1n
The only additional thing I did was to check for returned value. You should use Debug.Log() in Unity to print actual values obtained after deserialization.
Related
I am using an API for car HP and PCP details. When API returns the response object it has some dynamic object and objects names depending upon the parameters given during JSON call input parameters. Please tell me how can I convert / deserialize this response object into C# object. I tried JSON convert to C# classes but didn't get required results. Given below in API response object. I need to parse this result object into C# object so i can use it for displaying required values on front end.
JSON Response / Result Object
{
"success": true,
"data": {
"hp": {
"58995": {
"48": {
"40": {
"9000": [
{
"balance": 58955,
"first": 1403.62,
"regular": 1403.62,
"final": 1413.62,
"total": 67423.76,
"charges": 8428.76,
"apr": 6.92,
"apr_nofees": 6.91,
"term": 48,
"flat": 3.57,
"fee_front": "0.00",
"fee_back": "10.00",
"fee_spread": 0,
"ref": "1000.00",
"ho": 0,
"ho_a": 0,
"sb": 0,
"id": "12",
"product_name": "HP/ML No Fees",
"excess_mileage": false
}
]
}
}
}
},
"pcp": {
"58995": {
"48": {
"40": {
"9000": [
{
"balance": 58955,
"first": 1251.04,
"regular": 1251.04,
"final": 8386,
"total": 68475.92,
"charges": 9480.92,
"apr": 6.89,
"apr_nofees": 6.89,
"rv": 8385,
"term": 48,
"flat": 3.56,
"rv_interest": 1084.68,
"charges_ex_rv": 8396.24,
"fee_front": "0.00",
"fee_back": "1.00",
"fee_spread": 0,
"ref": 0,
"ho": 0,
"ho_a": 0,
"sb": 0,
"id": "25",
"product_name": "BNP PCP",
"excess_mileage": "7p"
}
]
}
}
}
},
"count": 2,
"taken": 443
}
}
try this
var jsonParsed = JObject.Parse(json);
var count = (int)jsonParsed["data"]["count"];
var taken = (int)jsonParsed["data"]["taken"];
((JObject)jsonParsed["data"]).Descendants()
.OfType<JProperty>()
.Where(attr => attr.Name == "count" || attr.Name == "taken")
.ToList()
.ForEach(attr => attr.Remove());
Data data = jsonParsed.ToObject<Data>();
data.count = count;
data.taken = taken;
classes
public class Data
{
public bool success { get; set; }
public Dictionary<string, Dictionary<string, Dictionary<string, Dictionary<string, Dictionary<string, Product[]>>>>> data { get; set; }
public int count { get; set; }
public int taken { get; set; }
public class Product
{
public int balance { get; set; }
public double first { get; set; }
public double regular { get; set; }
public double final { get; set; }
public double total { get; set; }
public double charges { get; set; }
public double apr { get; set; }
public double apr_nofees { get; set; }
public int term { get; set; }
public double flat { get; set; }
public string fee_front { get; set; }
public string fee_back { get; set; }
public int fee_spread { get; set; }
[JsonProperty("ref")]
public string refer { get; set; }
public int ho { get; set; }
public int ho_a { get; set; }
public int sb { get; set; }
public string id { get; set; }
public string product_name { get; set; }
public object excess_mileage { get; set; }
}
How can i deserialize a local json file to an object?
I'm trying to deserialize a local json file in xamarin but it just doesn't work i read many guides and watched some tutorials but none of them helped and most of them give the same code i'm using right now
My code:
public test()
{
InitializeComponent();
List<Rootobject> ob = new List<Rootobject>();
var assembly = IntrospectionExtensions.GetTypeInfo(typeof(test)).Assembly;
Stream stream = assembly.GetManifestResourceStream($"TunisiaPrayer.states.json");
string text = "";
using (var reader = new StreamReader(stream))
{
text = reader.ReadToEnd();
}
ob = JsonConvert.DeserializeObject<List<Rootobject>>(text);
//printing the json file to make sure it read it fully
//i get no error here
DisplayJson.Text = text;
//try catch to test if it was deserialized or not
try
{
//printing a property of ob in a label element to see if it works
DisplayData.Text = ob[2].Property1.data.gouvernorat.intituleAn;
}
catch (Exception ex)
{
DisplayData.Text = ex.Message;
}
}
RootObject Class:
namespace TunisiaPrayer.Models
{
public class Rootobject
{
public Class1 Property1 { get; set; }
}
public class Class1
{
public Data data { get; set; }
}
public class Data
{
public Gouvernorat gouvernorat { get; set; }
public Delegation[] delegation { get; set; }
}
public class Gouvernorat
{
public int id { get; set; }
public string intituleAr { get; set; }
public string intituleAn { get; set; }
}
public class Delegation
{
public int id { get; set; }
public string intituleAr { get; set; }
public string intituleAn { get; set; }
}
}
sample of states.json:
[{
"data": {
"gouvernorat": {
"id": 358,
"intituleAr": "اريانة",
"intituleAn": "Ariana"
},
"delegation": [{
"id": 631,
"intituleAr": "اريانة",
"intituleAn": "Ariana"
},
{
"id": 534,
"intituleAr": "التظامن",
"intituleAn": "Attadhamon"
},
{
"id": 532,
"intituleAr": "سكرة",
"intituleAn": "Soukra"
}
]
}
},
{
"data": {
"gouvernorat": {
"id": 362,
"intituleAr": "القصرين",
"intituleAn": "Kasserine"
},
"delegation": [{
"id": 579,
"intituleAr": "العيون",
"intituleAn": "El Ayoun"
},
{
"id": 576,
"intituleAr": "سبيبة",
"intituleAn": "Sbiba"
},
{
"id": 575,
"intituleAr": "سبيطلة",
"intituleAn": "Sbitla"
},
{
"id": 573,
"intituleAr": "تالة",
"intituleAn": "Tala"
}
]
}
}]
error: Object reference not set to an instance of an object
note that when i print ob.Count it gives me the correct length of the list but i can't access any data in it
you have to use Root[] , not just root, try this
var obj =JsonConvert.DeserializeObject< List<Root>>(text);
test
var displayData = obj[1].data.gouvernorat.intituleAn; // = Kasserine
classes
public class Root
{
public Data data { get; set; }
}
public class Data
{
public Gouvernorat gouvernorat { get; set; }
public List<Delegation> delegation { get; set; }
}
public class Gouvernorat
{
public int id { get; set; }
public string intituleAr { get; set; }
public string intituleAn { get; set; }
}
public class Delegation
{
public int id { get; set; }
public string intituleAr { get; set; }
public string intituleAn { get; set; }
}
I am trying to deserialize a object in C#, using NewtonSoft framework fro json handling. This is my code.
Brief Explanation
Essentially, I am creating a api call to the login endpoint to authenticate my user (this works), I need to extract the bearer token from the api call which returns a UserResponseDTO, this DTO contains the AuthToken attribute which I need to access, to pass my test cases.
Now this is the code of my test case.
[Fact]
public async void SuccessfulGetUserDetails()
{
//Arrange
//Arrange
var content = JsonConvert.SerializeObject(success); //Prepare payload
var buffer = System.Text.Encoding.UTF8.GetBytes(content);
var byteContent = new ByteArrayContent(buffer);
byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); //Set type to Json
//Act
var result = await _client.PostAsync("http://localhost:5000/api/Security/login", byteContent); //Send Request
var jsonstring = result.Content.ReadAsStringAsync().Result; //Get JSON String
UserResponseDTO dto = new UserResponseDTO();
dto = JsonConvert.DeserializeObject<UserResponseDTO>(jsonstring); //Deserialize
Assert.Equal(dto,null);
}
Now my last Assert check is to check if the DTO object is null....its not, but the values inside it are.
This is the UserResponseDTO
public class UserResponseDTO
{
public int UserId { get; set; }
public string AuthToken { get; set; }
public string UserName { get; set; }
public string FullName { get; set; }
public string Unit { get; set; }
public string IsActive { get; set; }
public string Mobile { get; set; }
public string Email { get; set; }
public List<UserRole> UserRole { get; set; }
public List<Menus> Menus { get; set;}
}
public class UserRole
{
public Role Role { get; set; }
}
public class Role
{
public int RoleId { get; set; }
public int ApplicationId { get; set; }
public string RoleDescription { get; set; }
public virtual List<RolePermission> RolePermission { get; set; }
public List<RoleMenu> RoleMenu { get; set; }
}
public class RoleMenu
{
public int RoleMenuId { get; set; }
public bool IsDefault { get; set; }
public virtual Menu Menu { get; set; }
}
public class RolePermission
{
public int RolePermissionId { get; set; }
public Permission Permission { get; set; }
}
public class Permission
{
public int PermissionId { get; set; }
public string Name { get; set; }
}
public class Menu
{
public int MenuId { get; set; }
public string Urlprefix { get; set; }
public string Url { get; set; }
public string Description { get; set; }
public bool IsParent { get; set; }
public bool IsActive { get; set; }
public int? ParentMenu { get; set; }
public string HtmlBody { get; set; }
public string CssClass { get; set; }
}
public class Menus
{
public bool isExternal { get; set; }
public string cssClass { get; set; }
public string routeLink { get; set; }
public string menuText { get; set; }
public List<SubMenuItems> subMenuItems { get; set; } = new List<SubMenuItems>();
}
public class SubMenuItems
{
public string routeLink { get; set; }
public string menuText { get; set; }
public string cssClass { get; set; }
}
Last but not least, I have noticed
THE CORRECT Json String is being returned however it is not being deserializd properly into a UserResponseDTO Object. And the values inside the DTO are all null.
What can I do to resolve this issue?
He is the JSON that is being returned in JSON String
Code of JSON as requested
"loginResponse": "Authenticated",
"userDetails": {
"userId": 3,
"authToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImFkbWluIiwibmJmIjoxNjIzMDM2OTkxLCJleHAiOjE2MjMwNDA1OTEsImlhdCI6MTYyMzAzNjk5MX0.wwIJ93syFnpcvjtw_Sj1s4uCtYPUtoROmwF3jkDZWo0",
"userName": "admin",
"fullName": "REDACTED",
"unit": null,
"isActive": "1",
"mobile": "+REDACTED",
"email": "REDACTED",
"userRole": [
{
"role": {
"roleId": 1,
"applicationId": 1,
"roleDescription": "Administrator",
"rolePermission": [
{
"rolePermissionId": 0,
"permission": {
"permissionId": 1,
"name": "CanApprove"
}
},
{
"rolePermissionId": 0,
"permission": {
"permissionId": 2,
"name": "CanReject"
}
},
{
"rolePermissionId": 0,
"permission": {
"permissionId": 3,
"name": "CanReview"
}
},
{
"rolePermissionId": 0,
"permission": {
"permissionId": 4,
"name": "CanDownload"
}
}
],
"roleMenu": [
{
"roleMenuId": 1,
"isDefault": true,
"menu": {
"menuId": 1,
"urlprefix": "UI",
"url": "worklist",
"description": "Menu",
"isParent": true,
"isActive": true,
"parentMenu": null,
"htmlBody": "<li><i class=\"fa fa-cog\"></i><span class=\"nav-label\">HEADING</span></li>",
"cssClass": "receipt"
}
},
{
"roleMenuId": 2,
"isDefault": false,
"menu": {
"menuId": 2,
"urlprefix": "UI",
"url": "reports",
"description": "Link 1",
"isParent": false,
"isActive": true,
"parentMenu": 1,
"htmlBody": "<li><i class=\"fa fa-plug\"></i><span class=\"nav-label\">HEADING</span></li>",
"cssClass": "fact_check"
}
},
{
"roleMenuId": 3,
"isDefault": false,
"menu": {
"menuId": 3,
"urlprefix": "UI",
"url": "generatefile",
"description": "Link 2",
"isParent": false,
"isActive": true,
"parentMenu": 1,
"htmlBody": "<li>HEADING</li>",
"cssClass": "file_present"
}
},
{
"roleMenuId": 9,
"isDefault": false,
"menu": {
"menuId": 4,
"urlprefix": "UI",
"url": "globalsearch",
"description": "Global Search",
"isParent": true,
"isActive": true,
"parentMenu": null,
"htmlBody": "<li>HEADING</li>",
"cssClass": "search"
}
}
]
}
}
],
"menus": [
{
"isExternal": false,
"cssClass": "receipt",
"routeLink": "worklist",
"menuText": "Menu",
"subMenuItems": [
{
"routeLink": "reports",
"menuText": "Link 1",
"cssClass": "fact_check"
},
{
"routeLink": "generatefile",
"menuText": "Link 2",
"cssClass": "file_present"
}
]
},
{
"isExternal": false,
"cssClass": "search",
"routeLink": "globalsearch",
"menuText": "Global Search",
"subMenuItems": []
}
]
}
}
Your json does not match the UserResponseDTO, you need add matched model like:
public class ResponseModel
{
public string LoginResponse { get; set; }
public UserResponseDTO UserDetails { get; set; }
}
If you do not want to add the response model, you need modify the json string to read userDetails:
//1. get the json string
string json = System.IO.File.ReadAllText("test.json");
//2. convert to JObject
var model = JObject.Parse(json);
//3. get userDetails json string
string jsonstring = model["userDetails"].ToString();
UserResponseDTO dto = new UserResponseDTO();
dto = JsonConvert.DeserializeObject<UserResponseDTO>(jsonstring);
Tried to parse JSON object using JavaScriptSerializer().Deserialize but getting thrown a null error at foreach (var item in getRoute.results) where Route getRoute = new JavaScriptSerializer().Deserialize<Route>(strresulttest);
The thing is, when I debugged strresulttest by printing out its contents, I was able to see my expected JSON output as shown here https://codeshare.io/5vM6X4
Code to parse JSON:
public class Route
{
public List<GetRoute> results { get; set; }
}
public class GetRoute
{
public string status_message { get; set; }
public string viaRoute { get; set; }
public string subtitle { get; set; }
public int totalTime { get; set; }
public int totalDistance { get; set; }
}
private void GetInstructions()
{
//GET METHOD for route query
string strurltest = String.Format("https://developers.onemap.sg/privateapi/routingsvc/route?start="+
startLat+","+ startLon +"&end="+ destinationLat +","+ destinationLon+"&"+
"routeType="+ transportType + "&token="+token);
WebRequest requestObjGet = WebRequest.Create(strurltest);
requestObjGet.Method = "GET";
HttpWebResponse responseObjGet = null;
responseObjGet = (HttpWebResponse)requestObjGet.GetResponse();
string strresulttest = null;
using (Stream stream = responseObjGet.GetResponseStream())
{
StreamReader sr = new StreamReader(stream);
strresulttest = sr.ReadToEnd();
//reminder: remove after prod. GET is working.
System.Diagnostics.Debug.WriteLine(strresulttest);
sr.Close();
}
//display search recommendations
Route getRoute = new JavaScriptSerializer().Deserialize<Route>(strresulttest);
foreach (var item in getRoute.results)
{
//reminder: remove after prod.
System.Diagnostics.Debug.WriteLine("Route via: " + item.viaRoute + "\n");
System.Diagnostics.Debug.WriteLine("Description: " + item.subtitle + "\n");
}
}
Expected JSON output (shown when System.Diagnostics.Debug.WriteLine(strresulttest);):
{
"status_message": "Found route between points",
"route_geometry": "m{`G_cyxRaAmALMtAyAj#g#RIZG|#KTC??RCxBQ\\KAOa#sDAQWwBM_AUmBEa#Ky#_#kDKoAIgAAs#Ce#?M|#_#PINUFk#Ik#e#aCu#wBeBoD_A}AmBqC{#iA_AeAyAqA{LmKmAu#k#g#y#Jk#r#k#r#GP#PFJhAt#oEnGw#i#QTMPs#g#}AzBr#d#JQ",
"status": 0,
"route_instructions": [
[
"Head",
"SINARAN DRIVE",
56,
"1.320394,103.844478",
18,
"56m",
"North East",
"North",
"driving",
"Head Northeast On Sinaran Drive"
],
[
...
],
...
],
"route_name": [
"MOULMEIN ROAD",
"WHAMPOA ROAD"
],
"route_summary": {
"start_point": "SINARAN DRIVE",
"end_point": "WHAMPOA ROAD",
"total_time": 390,
"total_distance": 2675
},
"viaRoute": "JALAN BAHAGIA",
"subtitle": "Fastest route, assuming usual traffic",
"phyroute": {
"status_message": "Found route between points",
"route_geometry": "m{`G_cyxRaAmALMtAyAj#g#RIZG|#KTC??Ao#BcB?kCBIHK|Ay#M_AUmBEa#Ky#_#kDKoAIgAAs#Ce#?M?OBw#BsCEq#Q{#Qm#KQGMaCNM#iFXO?sCNo#LCa#QaICe#EI?EBQTi#Ha##c#CMGWOYOOgEgD{BeBuB}AoEnGw#i#QTMPs#g#}AzBr#d#JQ",
"status": 0,
"route_instructions": [
[
"Head",
"SINARAN DRIVE",
56,
"1.320394,103.844478",
18,
"56m",
"North East",
"North",
"driving",
"Head Northeast On Sinaran Drive"
],
[
...
],
...
],
"route_name": [
...
],
"route_summary": {
...
},
"viaRoute": "BALESTIER ROAD",
"subtitle": "Shortest distance"
}
}
You are getting a null in results because the class structure that you are deserializing into does not match your JSON. The JSON you linked in your question corresponds to this class structure instead:
public class Route
{
public string status_message { get; set; }
public string route_geometry { get; set; }
public int status { get; set; }
public List<List<object>> route_instructions { get; set; }
public List<string> route_name { get; set; }
public RouteSummary route_summary { get; set; }
public string viaRoute { get; set; }
public string subtitle { get; set; }
public Phyroute phyroute { get; set; }
}
public class RouteSummary
{
public string start_point { get; set; }
public string end_point { get; set; }
public int total_time { get; set; }
public int total_distance { get; set; }
}
public class Phyroute
{
public string status_message { get; set; }
public string route_geometry { get; set; }
public int status { get; set; }
public List<List<object>> route_instructions { get; set; }
public List<string> route_name { get; set; }
public RouteSummary route_summary { get; set; }
public string viaRoute { get; set; }
public string subtitle { get; set; }
}
You can deserialize and get the viaRoute and subtitle like this:
Route route = new JavaScriptSerializer().Deserialize<Route>(strresulttest);
System.Diagnostics.Debug.WriteLine("Route via: " + route.viaRoute);
System.Diagnostics.Debug.WriteLine("Description: " + route.subtitle);
The problem is, I receive a list of posts from facebook (page feed) which occasionally holds multiple comments in an array inside the post object. Only the first comment of the post gets parsed correctly. Somehow the second and later comments don't get parsed.
This is the JSON I'm going on about:
{
"data": [ //Root object
{ //Post object
"id": "153411918116843_304953306296036",
"from": {
"category": "Sports/recreation/activities",
"category_list": [
{
"id": "124887510918208",
"name": "Swimming Pool"
}
],
"name": "Twentebad",
"id": "153411918116843"
},
"link": "http://dlvr.it/5bBKPx",
"picture": "irrelevant",
"message": "Onderzoek renovatie Twentebad! http://dlvr.it/5bBKPx",
"created_time": "2014-05-07T09:44:18+0000",
"comments": { // Collective comments object
// Actual comments objects in array !!!!! ONLY FIRST GETS PARSED !!!!
"data": [
{ //Comment object
"id": "304953306296036_304959069628793",
"from": {
"id": "884483928243965",
"name": "Selena Suzan Valentino"
},
"message": "Twentepalace",
"can_remove": false,
"created_time": "2014-05-07T10:32:26+0000",
"like_count": 0,
"user_likes": false
},
{ Unparsed comment object
"id": "304953306296036_305126702945363",
"from": {
"id": "884483928243965",
"name": "Selena Suzan Valentino"
},
"message": "Na baantjes trekken vooral heerlijk...",
"can_remove": false,
"created_time": "2014-05-08T09:12:43+0000",
"like_count": 0,
"user_likes": false
},
{ //Unparsed comment object
"id": "304953306296036_305126622945371",
"from": {
"id": "884483928243965",
"name": "Selena Suzan Valentino"
},
"message": "Wil infrarood sauna weer terug komt...",
"can_remove": false,
"created_time": "2014-05-08T09:11:20+0000",
"like_count": 0,
"user_likes": false
}
],
"paging": {
"cursors": {
"after": "MQ==",
"before": "Mw=="
}
},
"summary": {
"order": "ranked",
"total_count": 3
}
}
}
]
}
I'm using JSON.NET to parse this json to a typed object list like this:
foreach (JToken facebookItem in data["data"])
{
JToken messageCheck = facebookItem.SelectToken("message", false); //Irrelevante post als er geen inhoud in zit (false = geen error melding indien null)
if (messageCheck != null)
{
itemsToAdd.Add(facebookItem.ToObject<FacebookItem>());
}
}
The FacebookItem class looks like this:
public class FacebookItem
{
public string id { get; set; }
public From from { get; set; }
public string link { get; set; }
public string picture { get; set; }
public string message { get; set; }
public string created_time { get; set; }
public Comments comments { get; set; }
public PostPaging paging { get; set; }
public class PostCategories
{
public string id { get; set; }
public string name { get; set; }
}
public class From
{
public string category { get; set; }
public List<PostCategories> category_list { get; set; }
public string name { get; set; }
public string id { get; set; }
}
public class CommentCategories
{
public string id { get; set; }
public string name { get; set; }
}
//Root of Comments ("data":[ "comments":{ [],{},{} } ])
public class Comments
{
public List<CommentData> data { get; set; } //SHOULD HOLD MORE THAN 1
public CommentPaging paging { get; set; }
public Summary summary { get; set; }
}
//Data gegevens van comments ("data":[ "comments":{ "data":[],{},{} } ])
public class CommentData
{
public string id { get; set; }
public CommentFrom from { get; set; }
public string message { get; set; }
public bool can_remove { get; set; }
public string created_time { get; set; }
public int like_count { get; set; }
public bool user_likes { get; set; }
}
//Data gegevens van ccommenter ("data":[ "comments":{ "data":[ "from":{} ],{},{} } ])
public class CommentFrom
{
public string id { get; set; }
public string name { get; set; }
public string category { get; set; }
public List<CommentCategories> category_list { get; set; }
}
//Paging gegevens van comments ("data":[ "comments":{ [],"paging":{},{} } ])
public class CommentPaging
{
public Cursors cursors { get; set; }
}
//Summary gegevens van comments ("data":[ "comments":{ [],{},"summary":{} } ])
public class Summary
{
public string order { get; set; }
public int total_count { get; set; }
}
public class Cursors
{
public string after { get; set; }
public string before { get; set; }
}
public class PostPaging
{
public string previous { get; set; }
public string next { get; set; }
}
}
Is there a Json.net expert out there that undertands why only the first comment gets parsed?
This is what the debugger show me:
I'll tell you where I live, please come and kill me...
I called the url from localstorage. I changed the url but changes aren't detected so it doesn't get overwritten.
So, why only one comment? I had the comments' limit set to 1 :(
Not as exiting as I hoped this would be.
Hopefully the info provided can help someone in the future.