RestSharp - 序列化 @ 符号

RestSharp - Serializing an @ symbol

使用 RestSharp 105.2.3

与我通话的 API 要求使用 json 正文发送,但字段名称中包含 @c 符号。这在 C# 中当然是非法的,所以我不能只使用如下所示的动态对象。

有没有办法获取字段名称中的"@c"

        var client = new RestClient("https://aaa.bbb.com");
        var request = new RestRequest(Method.POST);
        request.AddJsonBody(new
        {
            @c=".Something",
            username="johnsmith"
        });

您可以只使用这样的字符串:

var client = new RestClient("https://aaa.bbb.com");
var request = new RestRequest(Method.POST);

string json = "{\"@c\":\".Something\", \"username\":\"johnsmith}";
request.AddJsonBody(json);