所以我有一个JSON字符串,我只想读取一个特定的值.我如何Read me please!从下面的字符串中选择" "?
var readString = /*Read me please!*/
Run Code Online (Sandbox Code Playgroud)
JSON字符串:
"{\"aString\":\"Read me please!\"}"
Run Code Online (Sandbox Code Playgroud)
为了更好地理解,我如何在这里做同样的事情?(只是" Read me please!"):
"{\"Result\":
{
\"aString\":\"Read me please!\",
\"anotherString\":\"Dont read me!\"
}
}"
Run Code Online (Sandbox Code Playgroud)
如果两种方案都有不同的解决方案,我想知道两者.
PS:我不希望将值保存到object/class左右.只是暂时在里面var readString.
如果我删除Tuple并使用Task<bool>或,这将有效Task<string>.
public async Tuple<Task<bool>, string> Test()
{
//....
return new Tuple<Task<bool>, string>(false, "a string");
}
Run Code Online (Sandbox Code Playgroud)
知道如何使这项工作?
我正在将JSON数据存储到课堂中.但是,我很难解决JSON下面的第二行,BadGuy.我无法正确存储数据.
{
\"First\":{\"FirstBool\":1, \"aString\":\"hello\"},
\"BadGuy\":\"BadGuy says hello\" //<--- this one, how do I tackle this in code below?
}
Run Code Online (Sandbox Code Playgroud)
public class First
{
[JsonProperty("FirstBool")]
public int FirstBool { get; set; }
[JsonProperty("aString")]
public string aString { get; set; }
}
public class BadGuy //my poorly attempt
{
[JsonProperty("BadGuy")]
public string BadGuy { get; set; }
}
public class ClsResult
{
[JsonProperty("First")]
public First First { get; set; }
[JsonProperty("BadGuy")] // another poorly attempt
public …Run Code Online (Sandbox Code Playgroud)