App crashes when deserializing JSON array of objects without name












0















I am currently working on a ListView which is showing several processes of our system. The system unfortunatedly only provide the json in the following format:



[
{
"f1": "w1",
"date": "2018.11.09"
},
{
"f1": "w2",
"date": "2018.11.09"
}
]


My app crashes if it starts the deserialization and I think the reason is, that the object has no "description". But how do I solve this?



this is my code for downloading and deserialize the json:



using (WebClient client = new WebClient())
{
client.Encoding = Encoding.UTF8;
json = client.DownloadString("http://x.x.x.x/test.json");
}
return JsonConvert.DeserializeObject<Query>(json);


Query:



public class Query
{
public List<Process> Processes { get; set; }
}


Process:



public class Process
{
[JsonProperty("f1")]
public string f1 { get; set; }
[JsonProperty("date")]
public string date { get; set; }
}









share|improve this question




















  • 1





    Show us Query please

    – Matt
    Nov 28 '18 at 13:16













  • try JsonConvert.DeserializeObject<List<Process>>(json);

    – Abdul Gani
    Nov 28 '18 at 13:30
















0















I am currently working on a ListView which is showing several processes of our system. The system unfortunatedly only provide the json in the following format:



[
{
"f1": "w1",
"date": "2018.11.09"
},
{
"f1": "w2",
"date": "2018.11.09"
}
]


My app crashes if it starts the deserialization and I think the reason is, that the object has no "description". But how do I solve this?



this is my code for downloading and deserialize the json:



using (WebClient client = new WebClient())
{
client.Encoding = Encoding.UTF8;
json = client.DownloadString("http://x.x.x.x/test.json");
}
return JsonConvert.DeserializeObject<Query>(json);


Query:



public class Query
{
public List<Process> Processes { get; set; }
}


Process:



public class Process
{
[JsonProperty("f1")]
public string f1 { get; set; }
[JsonProperty("date")]
public string date { get; set; }
}









share|improve this question




















  • 1





    Show us Query please

    – Matt
    Nov 28 '18 at 13:16













  • try JsonConvert.DeserializeObject<List<Process>>(json);

    – Abdul Gani
    Nov 28 '18 at 13:30














0












0








0








I am currently working on a ListView which is showing several processes of our system. The system unfortunatedly only provide the json in the following format:



[
{
"f1": "w1",
"date": "2018.11.09"
},
{
"f1": "w2",
"date": "2018.11.09"
}
]


My app crashes if it starts the deserialization and I think the reason is, that the object has no "description". But how do I solve this?



this is my code for downloading and deserialize the json:



using (WebClient client = new WebClient())
{
client.Encoding = Encoding.UTF8;
json = client.DownloadString("http://x.x.x.x/test.json");
}
return JsonConvert.DeserializeObject<Query>(json);


Query:



public class Query
{
public List<Process> Processes { get; set; }
}


Process:



public class Process
{
[JsonProperty("f1")]
public string f1 { get; set; }
[JsonProperty("date")]
public string date { get; set; }
}









share|improve this question
















I am currently working on a ListView which is showing several processes of our system. The system unfortunatedly only provide the json in the following format:



[
{
"f1": "w1",
"date": "2018.11.09"
},
{
"f1": "w2",
"date": "2018.11.09"
}
]


My app crashes if it starts the deserialization and I think the reason is, that the object has no "description". But how do I solve this?



this is my code for downloading and deserialize the json:



using (WebClient client = new WebClient())
{
client.Encoding = Encoding.UTF8;
json = client.DownloadString("http://x.x.x.x/test.json");
}
return JsonConvert.DeserializeObject<Query>(json);


Query:



public class Query
{
public List<Process> Processes { get; set; }
}


Process:



public class Process
{
[JsonProperty("f1")]
public string f1 { get; set; }
[JsonProperty("date")]
public string date { get; set; }
}






c# json xamarin.forms






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 28 '18 at 13:18









Rand Random

3,14673264




3,14673264










asked Nov 28 '18 at 13:15









paulvoelkerpaulvoelker

10911




10911








  • 1





    Show us Query please

    – Matt
    Nov 28 '18 at 13:16













  • try JsonConvert.DeserializeObject<List<Process>>(json);

    – Abdul Gani
    Nov 28 '18 at 13:30














  • 1





    Show us Query please

    – Matt
    Nov 28 '18 at 13:16













  • try JsonConvert.DeserializeObject<List<Process>>(json);

    – Abdul Gani
    Nov 28 '18 at 13:30








1




1





Show us Query please

– Matt
Nov 28 '18 at 13:16







Show us Query please

– Matt
Nov 28 '18 at 13:16















try JsonConvert.DeserializeObject<List<Process>>(json);

– Abdul Gani
Nov 28 '18 at 13:30





try JsonConvert.DeserializeObject<List<Process>>(json);

– Abdul Gani
Nov 28 '18 at 13:30












1 Answer
1






active

oldest

votes


















3














This is because JSON is trying to deserialise your values into a 'Query' object as specified:



{
"processes" :
}


When the result is a List, change the JsonConvert.DeserializeObject<Query> to JsonConvert.DeserializeObject<List<Process>>, and see if that helps :).






share|improve this answer



















  • 1





    YOU. ARE. A. GOD. Thank you!!!!!!

    – paulvoelker
    Nov 28 '18 at 13:24











  • Good. Samething I've answered in the question as a comment.

    – Abdul Gani
    Nov 28 '18 at 15:50











  • You know I posted this before you, right?

    – Tom Johnson
    Nov 28 '18 at 17:05











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53520332%2fapp-crashes-when-deserializing-json-array-of-objects-without-name%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














This is because JSON is trying to deserialise your values into a 'Query' object as specified:



{
"processes" :
}


When the result is a List, change the JsonConvert.DeserializeObject<Query> to JsonConvert.DeserializeObject<List<Process>>, and see if that helps :).






share|improve this answer



















  • 1





    YOU. ARE. A. GOD. Thank you!!!!!!

    – paulvoelker
    Nov 28 '18 at 13:24











  • Good. Samething I've answered in the question as a comment.

    – Abdul Gani
    Nov 28 '18 at 15:50











  • You know I posted this before you, right?

    – Tom Johnson
    Nov 28 '18 at 17:05
















3














This is because JSON is trying to deserialise your values into a 'Query' object as specified:



{
"processes" :
}


When the result is a List, change the JsonConvert.DeserializeObject<Query> to JsonConvert.DeserializeObject<List<Process>>, and see if that helps :).






share|improve this answer



















  • 1





    YOU. ARE. A. GOD. Thank you!!!!!!

    – paulvoelker
    Nov 28 '18 at 13:24











  • Good. Samething I've answered in the question as a comment.

    – Abdul Gani
    Nov 28 '18 at 15:50











  • You know I posted this before you, right?

    – Tom Johnson
    Nov 28 '18 at 17:05














3












3








3







This is because JSON is trying to deserialise your values into a 'Query' object as specified:



{
"processes" :
}


When the result is a List, change the JsonConvert.DeserializeObject<Query> to JsonConvert.DeserializeObject<List<Process>>, and see if that helps :).






share|improve this answer













This is because JSON is trying to deserialise your values into a 'Query' object as specified:



{
"processes" :
}


When the result is a List, change the JsonConvert.DeserializeObject<Query> to JsonConvert.DeserializeObject<List<Process>>, and see if that helps :).







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 28 '18 at 13:21









Tom JohnsonTom Johnson

539414




539414








  • 1





    YOU. ARE. A. GOD. Thank you!!!!!!

    – paulvoelker
    Nov 28 '18 at 13:24











  • Good. Samething I've answered in the question as a comment.

    – Abdul Gani
    Nov 28 '18 at 15:50











  • You know I posted this before you, right?

    – Tom Johnson
    Nov 28 '18 at 17:05














  • 1





    YOU. ARE. A. GOD. Thank you!!!!!!

    – paulvoelker
    Nov 28 '18 at 13:24











  • Good. Samething I've answered in the question as a comment.

    – Abdul Gani
    Nov 28 '18 at 15:50











  • You know I posted this before you, right?

    – Tom Johnson
    Nov 28 '18 at 17:05








1




1





YOU. ARE. A. GOD. Thank you!!!!!!

– paulvoelker
Nov 28 '18 at 13:24





YOU. ARE. A. GOD. Thank you!!!!!!

– paulvoelker
Nov 28 '18 at 13:24













Good. Samething I've answered in the question as a comment.

– Abdul Gani
Nov 28 '18 at 15:50





Good. Samething I've answered in the question as a comment.

– Abdul Gani
Nov 28 '18 at 15:50













You know I posted this before you, right?

– Tom Johnson
Nov 28 '18 at 17:05





You know I posted this before you, right?

– Tom Johnson
Nov 28 '18 at 17:05




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53520332%2fapp-crashes-when-deserializing-json-array-of-objects-without-name%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)