Json get Dictionary value

beantownace

Active member
Joined
Feb 15, 2019
Messages
26
Programming Experience
5-10
Hello all,

Question I have it best way to get this value. I have a string that comes back like this however the key can come back different so its not always InvoiceSvc it is pulling this from somewhere.
{ "InvoiceSvc" : "Password" }

All I am trying to do is simply get the password. So I am using Newtown json to Deserialize it to a Dictionary and looking to see how I get the first value. I only have it coming back as shown and tried to put it into a KeyValuePair but that did not work. How can I do this:

var result = "{ "InvoiceSvc" : "Password" }" //InvoiceSvc key will vary but its always the first value I need here

var dictionary = JsonSerliazer.Deserialize<Dictionary<string, string>>(result);

Thanks all
 
And what's wrong with using the LINQ First() extension on your dictionary to get the first entry found in the in memory dictionary representation of the JSON data?
 
Back
Top Bottom