locked
json returns nothing RRS feed

  • Question

  • User-1826478864 posted

    Code below contais json text where I want to get user_token. However when I use

    Dim deserialize = JsonConvert.DeserializeObject(Of User)(test)

    I get nothing. I tried of Response, request but still nothing.

    I've used http://json2csharp.com/ to generate classes

          Dim test = "{""response"":{""request"":{""date"":""Sun, 17 Mar 2013 20:41:08 +0100"",""resource"":""\/connections\/aaaaaaaa-3235-4766-b551-a1ede9be96fc.json"",""status"":{""flag"":""success"",""code"":200,""info"":""Your request has been processed successfully""}},""result"":{""status"":{""flag"":""success"",""code"":200,""info"":""The identity has been linked successfully""},""data"":{""plugin"":{""key"":""social_link"",""data"":{""action"":""link_identity"",""operation"":""identity_restored"",""reason"":""identity_exists_no_user_token_given"",""status"":""success""}},""connection"":{""connection_token"":""aaaaaaaa-3235-4766-b551-a1ede9be96fc"",""date"":""Sun, 17 Mar 2013 18:29:27 +0100""},""user"":{""user_token"":""aaaaaaaa-aaaa-aaaa-aaaa-aaa0975511a6"",""identity"":{""identity_token"":""aaaaaaaa-aaaa-4931-a8b5-b517a8ca05f6"",""provider"":""google"",""source"":{""name"":""Google"",""key"":""google""},""id"":""https:\/\/www.google.com\/accounts\/o8\/id?id=aaaaaaaaaaaaaaajrdCpNV5JPEa5zSdaBqalJP4"",""displayName"":""Katie Emil"",""name"":{""formatted"":""Katie Emil"",""givenName"":""Katie"",""familyName"":""Emil""},""currentLocation"":""GB"",""emails"":[{""value"":""aaa@aaa.com"",""is_verified"":true}],""urls"":[{""value"":""https:\/\/www.google.com\/profiles\/111111111112343246842"",""type"":""profile""}],""accounts"":[{""domain"":""google.com"",""userid"":""111111111112343246842""}],""languages"":[{""value"":""English""}]}}}}}}"
            Dim deserialize = JsonConvert.DeserializeObject(Of User)(test)


    Many thanks in advance

    Emil

    Sunday, March 17, 2013 4:02 PM

Answers

  • User-166373564 posted

    Hi,

    Because your codes are incomplete, I can hardly troubleshoot according to what you mentioned above, the example below will give good reference for you,

    Product product = new Product();
    
    product.Name = "Apple";
    
    product.Expiry = new DateTime(2008, 12, 28);
    
    product.Price = 3.99M;
    
    product.Sizes = new string[] { "Small", "Medium", "Large" };
    
     
    
    string json = JsonConvert.SerializeObject(product);
    
    Product deserializedProduct = JsonConvert.DeserializeObject<Product>(json);

    hope it helps you,

    With regards

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 20, 2013 5:38 AM