Home > Enterprise >  Is it okay to do the next class?
Is it okay to do the next class?

Time:04-09

Deserialization throws me an exception in the part

Path 'access', line 1, position 10.

I have part of the code like this

            Dim lstPyp As List(Of access) = Nothing
            lstPyp = JsonConvert.DeserializeObject(Of List(Of access))(strRespuesta)

The json is this

{
    "access": "granted",
    "last_login": "2022-04-07 10:30:07",
    "last_access": "2022-04-07 11:55:01",
    "uid": 5497,
    "user": "pepe",
    "id_comitente": 30,
    "profile": "comitente"
}

I have the class as follows

Public Class access


    Public Property access As String
    Public Property lastlogin As Date
    Public Property lastaccess As Date
    Public Property uid As Integer
    Public Property user As String
    Public Property idcomitente As Integer
    Public Property profile As String

end class

It is the first time that I have to do the classes.

CodePudding user response:

you don' t have any list, just one object so try this

Dim pyp As access =  JsonConvert.DeserializeObject(Of access)(strRespuesta)
  • Related