I ran into a funny situation.
I am using the BlockCypher API to generate crypto addresses, and what BlockCypher returns as a response is a Json object with the following fields: "address", "public", and "private".
This is my code:
HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync(endpoint);
if (response.IsSuccessStatusCode)
{
string json = await response.Content.ReadAsStringAsync();
dynamic dynamicJson = JsonConvert.DeserializeObject(json);
return new MyAddress()
{
Address = (string)dynamicJson.address,
PublicKey = (string)dynamicJson.public,
PrivateKey = (string)dynamicJson.private
};
}
but I am having problems since public
and private
are keywords in C# :)
Obviously, there are many alternatives, such as using dynamicJson["public"]
or deserializing into an existing class to avoid dynamic
, but I am just wondering if there is a way to escape these keywords or some other workaround.