zrg
2025-02-19 0034934486fcf6166cea4652e91b11a1b0dc3fce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using FastJSON;
using System;
using System.Collections;
 
namespace Top.Api.Parser
{
    public class TopSimplifyJsonParser<T> : TopJsonParser<T> where T : TopResponse
    {
        public override T Parse(string body)
        {
            T rsp = null;
 
            IDictionary rootJson = JSON.Parse(body) as IDictionary;
            if (rootJson != null)
            {
                IDictionary data = rootJson;
                if (rootJson.Contains(Constants.ERROR_RESPONSE))
                {
                    data = rootJson[Constants.ERROR_RESPONSE] as IDictionary;
                }
 
                if (data != null)
                {
                    ITopReader reader = new TopSimplifyJsonReader(data);
                    rsp = (T)FromJson(reader, typeof(T));
                }
            }
 
            if (rsp == null)
            {
                rsp = Activator.CreateInstance<T>();
            }
 
            if (rsp != null)
            {
                rsp.Body = body;
            }
 
            return rsp;
        }
    }
}