Reputation: 25
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.
Upvotes: 0
Views: 1194
Reputation: 373
Try using
[JsonPropertyName("@Scope")]
Instead of
[JsonProperty("@Scope")]
JsonProperty
might be for Newtonsoft which the built in serialization library probably does not recognize.
Upvotes: 1