Click here to Skip to main content
15,793,452 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have the following code to connect to a Json on a server.
I can connected and read the file succesfully.
But i just want now to extract some fields, really i am stocked: I don't know
even i have seen at lot examples (Including one in this forum)

public List<Paquete> GetPaquete()

          url = url + codigo + clave + keyAPI + keyPaso;
          RestClient client = new RestClient(url);

          RestRequest request = new RestRequest(url, Method.Get);
          request.RequestFormat = DataFormat.Json;
          request.AddHeader("Context-Type", "application/json");
          var response = client.Execute(request);

          if (response.IsSuccessful)
              var listadof = JsonConvert.DeserializeObject<List<Paquete>>(url);
              var peso = listadof[0];

              return listadof;
              var error = response.ErrorMessage;

          return null;

Also i have this class
public class Paquete
    public string peso { get; set; }

    public string trackingNumber { get; set; }

What I have tried:

Trying to deserialized a json from a server
Updated 21-Jul-22 4:39am

1 solution

I have written an article that will answer this question and more: Working with JSON in C# & VB[^]
Share this answer
Luis M. Rojas 21-Jul-22 10:20am    
Excellent, that is it. Great. Thanks at lot. it is works

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900