Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Json deserialization

$
0
0

I have this class:

public class StatusItem
{

        public string Status { get; set; }
        public string Status_message { get; set; }
    }

and this JSON string:

"{\"status\":1,\"status_message\":\"Actualization updated successfully.\"}"

Using This

var user = JsonConvert.DeserializeObject<List<StatusItem>>(content);

I got this error:

Newtonsoft.Json.JsonSerializationException:
Cannot deserialize the current JSON object (e.g. {"name":"value"})
into type 'System.Collections.Generic.List`1[Cesis02.RestServices.StatusItem]'
because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3])
or change the deserialized type so that it is a normal .NET type (e.g. not a
primitive type like integer, not a collection type like an array or List)
that can be deserialized from a JSON object. JsonObjectAttribute can also be
added to the type to force it to deserialize from a JSON object.

Anybody can help me on how to solve ? I´m new with XamarinForms.


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>