Új hozzászólás Aktív témák

  • trisztan94

    őstag

    válasz martonx #5275 üzenetére

    Hát én nem találtam meg azt az automatikus generálás cuccost.

    Írtam egy ilyen model osztályt:

    public class Nevek
    {
    public string id; //az id is stringként jön át
    public string nev;
    }

    És ezt csináltam:

    Nevek responseData = JsonConvert.DeserializeObject<Nevek>(response.Content);

    Hibaüzenet:

    An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.DLL but was not handled in user code

    Additional information: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Click4Skill_Angol.Model.Nevek' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.

    Mint ahogy előbb írtam, ez a szervertől visszakapott json string:

    "[{\"id\":\"1\",\"nev\":\"Aladár\"},{\"id\":\"2\",\"nev\":\"Béla\"}]"

    Mit csinálok rosszul? :F :F

Új hozzászólás Aktív témák

Hirdetés