1

I have a JWT that I want to display its contents after signature validation. so, I verify the signature like this:

var verified = JWT.Decode(token, publicKey); 

In this case, verified is a string containing the JSON payload, looks something like this:

{"sub":"211668914321303","aud":"MUSCA","ver":"1.0.0","nbf":1544459925,"iss":"blimp gmbh","rle":"MUSCA_ACCESS","prm":"This chunk is bound to the something for blimp gmbh","exp":4703150773,"iat":1544459925,"jti":"46"} 

now to view this on a page in form of a table, it's easier to send it as a JSON, and loop on its Type and Value, like this:

var verifiedJSON = JsonConvert.DeserializeObject(verified); //convert to JSON ViewBag.payload = verifiedJSON 

in my view, I loop on the ViewBag like this

<table class="table-bordered table-responsive"> @foreach (var line in ViewBag.payload) { <tr> <td>@line.Type</td> <td>@line.Value</td> </tr> } 

I would expect that the table will show type and value in columns, but instead of the type(key), I get the word Property, with the expected value in each row!

faulty table

I tried to display the JSON below the table to see if it came with "property" in the key fields, but it viewed with the correct key names. am I missing something or why can't I get the table to view the keys correctly?

1
  • 1
    You're doing line.Type (which of course will return Property... as it's basically the Type of the Key (in the key:value pair)). I'm not sure what's the correct one off the top of my head but it should be something like line.Key (As in the name of the key)CommentedJan 17, 2019 at 17:53

1 Answer 1

1

I found the issue thanks to jabberwocky I copied a table that was looping on an IEnumerable, and changed the variable which is a JSON, and by referring to Json.NET Documentation, I found out that the Key is not called Key or Type. It is called Name

1
  • 1
    Glad I could help dude. CheersCommentedJan 18, 2019 at 10:41

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.