Posts

Showing posts with the label assert

Extract value for key from json c#

Extract value for key from json c# I have the following Json (is a file attached to the project): { "Errors": { "NoCountry": { "MSG": "The CountryCode field is required.", "Description": "Error encountered when Country parameter is missing from the request" }, "NoLOI": { "MSG": "Validation failed: rn -- LengthOfInterview cannot be empty" "Description": "Error encountered when LOI parameter is missing from the request" } } } I need to extract the values for e.g. Errors.NoCompletes.MSG in order to use it in an assert to compare it with an output that i get from the API. Till now i tried to create a dictionary that looks like this: public class ErrorsDictionary { public string MSG; public string Description; } public class DicRoot { public Dictionary<string, ErrorsDictionary> Errors { set; get; } } And use it like this: Dic...