JsonSchema 解析示例


 1     /// <summary>
 2     /// JsonSchema Parse Demo
 3     /// </summary>
 4     public class JsonSchema
 5     {
 6         private int RecursionCnt = 0;
 7         private int RecursionCntMax = 100;
 8 
 9         public void Parse(dynamic schema)
10         {
11             RecursionCnt = RecursionCnt + 1;
12 
13             if (RecursionCnt > RecursionCntMax)
14             {
15                 return;
16             }
17 
18             if (schema.items != null)
19             {
20                 Parse(schema.items);
21             }
22 
23             if (schema.properties != null)
24             {
25                 foreach (var property in schema.properties)
26                 {
27                     if (property.Value.objectname == null)
28                     {
29                         foreach (var item in property)
30                         {
31                             Parse(item);
32                         }
33                     }
34                     else
35                     {
36                         //獲取需要的鍵值對(Key對name的value)
37                         string name = property.Value.name;
38                     }
39                 }
40             }
41         }
42     }

       

        JsonSchema 參見:http://json-schema.org/
        Json.NET Schema 參見:https://www.newtonsoft.com/jsonschema


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM