文字列を使用してデータ型間を変換できますか?私は次のJSONを受け取るAzure関数を書いています。文字列を使用してデータ型間を変換できますか?
{
"data": "1",
"type": "int"
}
そして、私はintとして "1"を返します。私は、これまで行ってきた:
dynamic body = await req.Content.ReadAsStringAsync();
Data data = JsonConvert.DeserializeObject<Data>(body as string);
データクラス:
public class Data
{
public string data { get; set; },
public string type { get; set; }
}
ありがとうございました。あなたの"type"
で
'dynamic'は必要ありません。' ReadAsStringAsync'は文字列を返します。 – Crowcoder
ありがとう、私はそれを知らなかった。 – FXux
なぜ賛成投票ですか? – FXux