2

I get the content from a api response like this:

var response = await httpClient.GetAsync(new Uri("http://localhost:1337/" + route));
var responseContent = await response.Content.ReadAsStringAsync();

responseContent looks like this:

[{"caption":"Type Value List","name":"ReportsTypeValueList","visible":true,"enabled":true,"controlName":null,"elements":[{"caption":"Detail","name":"Detail","visible":true,"enabled":true,....

I parsed it into a Json array.

One of the json objects inside the json array has a property called defaultValue with timestamp as it's value looking like this for example:

"defaultValue": "2019-07-18T11:29:13.623245Z"

How can I remove this property from the Json array?

4
  • Understanding why you need it removed might help. Commented Jul 18, 2019 at 13:08
  • what lib are you using for parsing the json objects?? Json.Net?? Commented Jul 18, 2019 at 13:10
  • You parsed it to a JArray if you're using Json.NET. There's no such thing as a "Json array". Commented Jul 18, 2019 at 13:13
  • i thought JArray means Json Array Commented Jul 18, 2019 at 13:29

2 Answers 2

2

Assuming you are using a Json.Net lib then you can do

JObject myJsonResponse = JObject.Parse(responseContent);
myJsonResponse.Property("defaultValue").Remove();
Sign up to request clarification or add additional context in comments.

Comments

0

You can use this.

array.Children<JObject>().FirstOrDefault(x => x.Value<string> 
("defaultValue") == "2019-07-18T11:29:13.623245Z").
Property("defaultValue").Remove();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.