0

I need to send via REST (not including some other sensitive information):

{"@Scope": "Local"}

In the class file I JsonProperty for Json.Net serialization:

[JsonProperty("@Scope")]
public string Scope { get; set; }

When putting together the json message to be sent via WebRequest, I have

{@Scope = "Local"}

But after running:

string jsonString = System.Text.Json.JsonSerializer.Serialize(message);

The message being sent out is

{"Scope": "Local"}

For some reason I though System.Text.Json will pick up JsonProperty attributes but apparently there should be some other way.

4

1 Answer 1

1

Try using

[JsonPropertyName("@Scope")]

Instead of

[JsonProperty("@Scope")]

JsonProperty might be for Newtonsoft which the built in serialization library probably does not recognize.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the quick response. This seems to work.

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.