Edit time: 2017-05-10. Add a method to transform list
First, I know a way to parse JSON string before, I find it a little troublesome. I got another one from somewhere else
string json = vlt.getlist(); JObject jo = JObject.Parse(json); var data = jo.getValue("data").ToObject<T>();
T is the corresponding entity class, and can be used directly in the member variable data.member
2. Json transformation of the List is to put it into redIS cache, and then take it out for transformation
Don’t talk nonsense, code on:
var t = new List<PcWareListByCourseId>(); var m1 = new PcWareListByCourseId { videoId = 12, IsAuditions = false, percent = 23, practiceId = 43, statuss = 2, TotalTime = "12.2", wareId = 22, wareName = "courseware" }; var m2 = new PcWareListByCourseId { videoId = 12, IsAuditions = false, percent = 23, practiceId = 43, statuss = 2, TotalTime = "12.2", wareId = 22, wareName = "courseware" }; t.Add(m1); t.Add(m2); RedisInfoHelper.SetRedis("test",t); var get = RedisInfoHelper.GetRedisValue("test"); var jo = JArray.Parse(get); var jj = jo.ToObject<List<PcWareListByCourseId>>();
Entity code:
public class PcWareListByCourseId { public int wareId { set; get; } public string wareName { set; get; } public bool IsAuditions { set; get; } public int videoId { set; get; } public int percent { set; get; } public int practiceId { set; get; } public int statuss { set; get; } public string TotalTime { set; get; }//11'22" }
Successful to the last step, successful transformation.
This time I’m using the JArray method class.
Read More:
- JSON parse error: Can not deserialize instance of java.lang.String out of START_OBJECT token
- [Solved] SyntaxError:JSON.parse:unexpected character at line 1 column 1 of the JSON data
- [Solved] JSON parse error: Unexpected character (‘‘‘ (code 39)): was expecting double-quote to start ……
- [Solved] Interface automation test: JSON parse error
- [Solved] JSON parse error: Unexpected character (‘‘‘ (code 39)): was expecting double-quote to star
- JSON parse error: raw timestamp (1595952000000) not allowed for
- net.sf.json .JSONObject maven20381;- 36182;
- How to Solve brew ERROR in `initialize‘: Version value must be a string; got a NilClass ()
- How to Solve “Status bar could not find cached time string image. Rendering in-process.” in Xcode
- PHP Parse error: syntax error, unexpected ‘class‘ (T_CLASS), expecting identifier (T_STRING)
- How to Solve Chrome Error: net::ERR_FAILED
- How to Solve error C2039: “to_ String “: not a member of” STD “
- Template cannot be rendered due to the joint query of populate in mongoose: syntax error: unexpected token r in JSON at position 0
- How to Solve args = parser.parse_args() error
- How to Solve Internal Server Error: /swagger/v1/swagger.json
- Keytool: How to solve javax.net.ssl.SSLHandshakeException Error?
- [Solved] Parsing JSON error unexpected end of JSON input
- [Solved] Compile the program error: undefined reference to `cv::dnn::dnn4_v20210301::Net::~Net()‘
- Json: struct field readyReplicas has json tag but is not exported [How to Solve]
- The problem of using GB2312 encoding in .NET Core to report errors