Mercurial > pub > ImplabNet
annotate Implab/Xml/JsonXmlReader.cs @ 264:3a6e18c432be v3
Added XmlToJson xsl transformation.
Added JsonXmlReader.CreateJsonXmlReader(...) methods
Added SerializationHelpers.SerializeJson/DeserializeJson methods
author | cin |
---|---|
date | Mon, 16 Apr 2018 18:43:49 +0300 |
parents | 7c7e9ad6fe4a |
children | 74e048cbaac8 |
rev | line source |
---|---|
228 | 1 using Implab.Formats.Json; |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
2 using System; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
3 using System.Collections.Generic; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
4 using System.Globalization; |
264 | 5 using System.IO; |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
6 using System.Linq; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
7 using System.Xml; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
8 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
9 namespace Implab.Xml { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
10 public class JsonXmlReader : XmlReader { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
11 struct JsonContext { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
12 public string localName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
13 public bool skip; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
14 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
15 |
229 | 16 JsonReader m_parser; |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
17 JsonXmlReaderOptions m_options; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
18 JsonXmlReaderPosition m_position = JsonXmlReaderPosition.Initial; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
19 XmlNameTable m_nameTable; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
20 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
21 readonly string m_jsonRootName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
22 readonly string m_jsonNamespace; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
23 readonly string m_jsonPrefix; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
24 readonly bool m_jsonFlattenArrays; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
25 readonly string m_jsonArrayItemName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
26 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
27 string m_jsonLocalName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
28 string m_jsonValueName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
29 bool m_jsonSkip; // indicates wheather to generate closing tag for objects or arrays |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
30 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
31 readonly Stack<JsonContext> m_jsonNameStack = new Stack<JsonContext>(); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
32 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
33 XmlQualifiedName m_elementQName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
34 string m_elementPrefix; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
35 int m_elementDepth; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
36 bool m_elementIsEmpty; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
37 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
38 XmlQualifiedName m_qName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
39 string m_prefix; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
40 int m_xmlDepth; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
41 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
42 XmlSimpleAttribute[] m_attributes; |
236 | 43 string m_value; |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
44 bool m_isEmpty; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
45 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
46 XmlNodeType m_nodeType = XmlNodeType.None; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
47 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
48 bool m_isAttribute; // indicates that we are reading attribute nodes |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
49 int m_currentAttribute; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
50 bool m_currentAttributeRead; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
51 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
52 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
53 XmlNameContext m_context; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
54 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
55 readonly string m_xmlnsPrefix; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
56 readonly string m_xmlnsNamespace; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
57 readonly string m_xsiPrefix; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
58 readonly string m_xsiNamespace; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
59 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
60 |
229 | 61 public JsonXmlReader(JsonReader parser, JsonXmlReaderOptions options) { |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
62 Safe.ArgumentNotNull(parser, nameof(parser)); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
63 m_parser = parser; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
64 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
65 m_options = options ?? new JsonXmlReaderOptions(); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
66 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
67 m_jsonFlattenArrays = m_options.FlattenArrays; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
68 m_nameTable = m_options.NameTable ?? new NameTable(); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
69 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
70 m_jsonRootName = m_nameTable.Add(string.IsNullOrEmpty(m_options.RootName) ? "data" : m_options.RootName); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
71 m_jsonArrayItemName = m_nameTable.Add(string.IsNullOrEmpty(m_options.ArrayItemName) ? "item" : m_options.ArrayItemName); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
72 m_jsonNamespace = m_nameTable.Add(m_options.NamespaceUri ?? string.Empty); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
73 m_jsonPrefix = m_nameTable.Add(m_options.NodesPrefix ?? string.Empty); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
74 m_xmlnsPrefix = m_nameTable.Add(XmlNameContext.XmlnsPrefix); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
75 m_xmlnsNamespace = m_nameTable.Add(XmlNameContext.XmlnsNamespace); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
76 m_xsiPrefix = m_nameTable.Add(XmlNameContext.XsiPrefix); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
77 m_xsiNamespace = m_nameTable.Add(XmlNameContext.XsiNamespace); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
78 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
79 // TODO validate m_jsonRootName, m_jsonArrayItemName |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
80 |
229 | 81 m_context = new XmlNameContext(null, 0); |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
82 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
83 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
84 public override int AttributeCount { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
85 get { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
86 return m_attributes == null ? 0 : m_attributes.Length; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
87 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
88 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
89 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
90 public override string BaseURI { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
91 get { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
92 return string.Empty; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
93 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
94 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
95 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
96 public override int Depth { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
97 get { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
98 return m_xmlDepth; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
99 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
100 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
101 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
102 public override bool EOF { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
103 get { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
104 return m_position == JsonXmlReaderPosition.Eof; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
105 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
106 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
107 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
108 public override bool IsEmptyElement { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
109 get { return m_isEmpty; } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
110 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
111 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
112 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
113 public override string LocalName { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
114 get { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
115 return m_qName.Name; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
116 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
117 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
118 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
119 public override string NamespaceURI { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
120 get { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
121 return m_qName.Namespace; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
122 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
123 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
124 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
125 public override XmlNameTable NameTable { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
126 get { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
127 return m_nameTable; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
128 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
129 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
130 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
131 public override XmlNodeType NodeType { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
132 get { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
133 return m_nodeType; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
134 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
135 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
136 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
137 public override string Prefix { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
138 get { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
139 return m_prefix; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
140 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
141 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
142 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
143 public override ReadState ReadState { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
144 get { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
145 switch (m_position) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
146 case JsonXmlReaderPosition.Initial: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
147 return ReadState.Initial; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
148 case JsonXmlReaderPosition.Eof: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
149 return ReadState.EndOfFile; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
150 case JsonXmlReaderPosition.Closed: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
151 return ReadState.Closed; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
152 case JsonXmlReaderPosition.Error: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
153 return ReadState.Error; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
154 default: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
155 return ReadState.Interactive; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
156 }; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
157 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
158 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
159 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
160 public override string Value { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
161 get { |
236 | 162 return m_value; |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
163 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
164 } |
236 | 165 |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
166 public override string GetAttribute(int i) { |
251 | 167 Safe.ArgumentInRange(i >= 0 && i < AttributeCount, nameof(i)); |
236 | 168 return m_attributes[i].Value; |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
169 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
170 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
171 public override string GetAttribute(string name) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
172 if (m_attributes == null) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
173 return null; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
174 var qName = m_context.Resolve(name); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
175 var attr = Array.Find(m_attributes, x => x.QName == qName); |
236 | 176 var value = attr?.Value; |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
177 return value == string.Empty ? null : value; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
178 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
179 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
180 public override string GetAttribute(string name, string namespaceURI) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
181 if (m_attributes == null) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
182 return null; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
183 var qName = new XmlQualifiedName(name, namespaceURI); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
184 var attr = Array.Find(m_attributes, x => x.QName == qName); |
236 | 185 var value = attr?.Value; |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
186 return value == string.Empty ? null : value; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
187 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
188 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
189 public override string LookupNamespace(string prefix) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
190 return m_context.ResolvePrefix(prefix); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
191 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
192 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
193 public override bool MoveToAttribute(string name) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
194 if (m_attributes == null || m_attributes.Length == 0) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
195 return false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
196 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
197 var qName = m_context.Resolve(name); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
198 var index = Array.FindIndex(m_attributes, x => x.QName == qName); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
199 if (index >= 0) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
200 MoveToAttributeImpl(index); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
201 return true; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
202 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
203 return false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
204 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
205 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
206 public override bool MoveToAttribute(string name, string ns) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
207 if (m_attributes == null || m_attributes.Length == 0) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
208 return false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
209 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
210 var qName = m_context.Resolve(name); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
211 var index = Array.FindIndex(m_attributes, x => x.QName == qName); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
212 if (index >= 0) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
213 MoveToAttributeImpl(index); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
214 return true; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
215 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
216 return false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
217 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
218 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
219 void MoveToAttributeImpl(int i) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
220 if (!m_isAttribute) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
221 m_elementQName = m_qName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
222 m_elementDepth = m_xmlDepth; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
223 m_elementPrefix = m_prefix; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
224 m_elementIsEmpty = m_isEmpty; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
225 m_isAttribute = true; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
226 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
227 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
228 var attr = m_attributes[i]; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
229 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
230 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
231 m_currentAttribute = i; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
232 m_currentAttributeRead = false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
233 m_nodeType = XmlNodeType.Attribute; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
234 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
235 m_xmlDepth = m_elementDepth + 1; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
236 m_qName = attr.QName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
237 m_value = attr.Value; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
238 m_prefix = attr.Prefix; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
239 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
240 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
241 public override bool MoveToElement() { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
242 if (m_isAttribute) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
243 m_value = null; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
244 m_nodeType = XmlNodeType.Element; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
245 m_xmlDepth = m_elementDepth; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
246 m_prefix = m_elementPrefix; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
247 m_qName = m_elementQName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
248 m_isEmpty = m_elementIsEmpty; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
249 m_isAttribute = false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
250 return true; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
251 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
252 return false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
253 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
254 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
255 public override bool MoveToFirstAttribute() { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
256 if (m_attributes != null && m_attributes.Length > 0) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
257 MoveToAttributeImpl(0); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
258 return true; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
259 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
260 return false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
261 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
262 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
263 public override bool MoveToNextAttribute() { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
264 if (m_isAttribute) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
265 var next = m_currentAttribute + 1; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
266 if (next < AttributeCount) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
267 MoveToAttributeImpl(next); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
268 return true; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
269 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
270 return false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
271 } else { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
272 return MoveToFirstAttribute(); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
273 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
274 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
275 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
276 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
277 public override bool ReadAttributeValue() { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
278 if (!m_isAttribute || m_currentAttributeRead) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
279 return false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
280 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
281 ValueNode(m_attributes[m_currentAttribute].Value); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
282 m_currentAttributeRead = true; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
283 return true; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
284 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
285 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
286 public override void ResolveEntity() { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
287 /* do nothing */ |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
288 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
289 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
290 /// <summary> |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
291 /// Determines do we need to increase depth after the current node |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
292 /// </summary> |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
293 /// <returns></returns> |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
294 public bool IsSibling() { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
295 switch (m_nodeType) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
296 case XmlNodeType.None: // start document |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
297 case XmlNodeType.Attribute: // after attribute only it's content can be iterated with ReadAttributeValue method |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
298 return false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
299 case XmlNodeType.Element: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
300 // if the elemnt is empty the next element will be it's sibling |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
301 return m_isEmpty; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
302 default: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
303 return true; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
304 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
305 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
306 |
236 | 307 void ValueNode(string value) { |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
308 if (!IsSibling()) // the node is nested |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
309 m_xmlDepth++; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
310 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
311 m_qName = XmlQualifiedName.Empty; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
312 m_nodeType = XmlNodeType.Text; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
313 m_prefix = string.Empty; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
314 m_value = value; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
315 m_isEmpty = false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
316 m_attributes = null; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
317 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
318 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
319 void ElementNode(string name, string ns, XmlSimpleAttribute[] attrs, bool empty) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
320 if (!IsSibling()) // the node is nested |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
321 m_xmlDepth++; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
322 |
229 | 323 var context = m_context; |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
324 List<XmlSimpleAttribute> definedAttrs = null; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
325 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
326 // define new namespaces |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
327 if (attrs != null) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
328 foreach (var attr in attrs) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
329 if (attr.QName.Name == "xmlns") { |
229 | 330 if (context == m_context) |
331 context = new XmlNameContext(m_context, m_xmlDepth); | |
236 | 332 context.DefinePrefix(attr.Value, string.Empty); |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
333 } else if (attr.Prefix == m_xmlnsPrefix) { |
229 | 334 if (context == m_context) |
335 context = new XmlNameContext(m_context, m_xmlDepth); | |
236 | 336 context.DefinePrefix(attr.Value, attr.QName.Name); |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
337 } else { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
338 string attrPrefix; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
339 if (string.IsNullOrEmpty(attr.QName.Namespace)) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
340 continue; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
341 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
342 // auto-define prefixes |
229 | 343 if (!context.LookupNamespacePrefix(attr.QName.Namespace, out attrPrefix) || string.IsNullOrEmpty(attrPrefix)) { |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
344 // new namespace prefix added |
229 | 345 attrPrefix = context.CreateNamespacePrefix(attr.QName.Namespace); |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
346 attr.Prefix = attrPrefix; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
347 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
348 if (definedAttrs == null) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
349 definedAttrs = new List<XmlSimpleAttribute>(); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
350 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
351 definedAttrs.Add(new XmlSimpleAttribute(attrPrefix, m_xmlnsNamespace, m_xmlnsPrefix, attr.QName.Namespace)); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
352 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
353 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
354 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
355 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
356 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
357 string p; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
358 // auto-define prefixes |
229 | 359 if (!context.LookupNamespacePrefix(ns, out p)) { |
360 if (context == m_context) | |
361 context = new XmlNameContext(m_context, m_xmlDepth); | |
362 p = context.CreateNamespacePrefix(ns); | |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
363 if (definedAttrs == null) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
364 definedAttrs = new List<XmlSimpleAttribute>(); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
365 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
366 definedAttrs.Add(new XmlSimpleAttribute(p, m_xmlnsNamespace, m_xmlnsPrefix, ns)); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
367 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
368 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
369 if (definedAttrs != null) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
370 if (attrs != null) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
371 definedAttrs.AddRange(attrs); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
372 attrs = definedAttrs.ToArray(); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
373 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
374 |
229 | 375 if (!empty) |
376 m_context = context; | |
377 | |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
378 m_nodeType = XmlNodeType.Element; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
379 m_qName = new XmlQualifiedName(name, ns); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
380 m_prefix = p; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
381 m_value = null; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
382 m_isEmpty = empty; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
383 m_attributes = attrs; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
384 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
385 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
386 void EndElementNode(string name, string ns) { |
229 | 387 if (IsSibling()) { |
388 // closing the element which has children | |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
389 m_xmlDepth--; |
229 | 390 } |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
391 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
392 string p; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
393 if (!m_context.LookupNamespacePrefix(ns, out p)) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
394 throw new Exception($"Failed to lookup namespace '{ns}'"); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
395 |
229 | 396 if (m_context.Depth == m_xmlDepth) |
397 m_context = m_context.ParentContext; | |
398 | |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
399 m_nodeType = XmlNodeType.EndElement; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
400 m_prefix = p; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
401 m_qName = new XmlQualifiedName(name, ns); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
402 m_value = null; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
403 m_attributes = null; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
404 m_isEmpty = false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
405 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
406 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
407 void XmlDeclaration() { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
408 if (!IsSibling()) // the node is nested |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
409 m_xmlDepth++; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
410 m_nodeType = XmlNodeType.XmlDeclaration; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
411 m_qName = new XmlQualifiedName("xml"); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
412 m_value = "version='1.0'"; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
413 m_prefix = string.Empty; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
414 m_attributes = null; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
415 m_isEmpty = false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
416 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
417 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
418 public override bool Read() { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
419 try { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
420 string elementName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
421 XmlSimpleAttribute[] elementAttrs = null; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
422 MoveToElement(); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
423 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
424 switch (m_position) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
425 case JsonXmlReaderPosition.Initial: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
426 m_jsonLocalName = m_jsonRootName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
427 m_jsonSkip = false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
428 XmlDeclaration(); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
429 m_position = JsonXmlReaderPosition.Declaration; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
430 return true; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
431 case JsonXmlReaderPosition.Declaration: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
432 elementAttrs = new[] { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
433 new XmlSimpleAttribute(m_xsiPrefix, m_xmlnsNamespace, m_xmlnsPrefix, m_xsiNamespace), |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
434 string.IsNullOrEmpty(m_jsonPrefix) ? |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
435 new XmlSimpleAttribute(m_xmlnsPrefix, string.Empty, string.Empty, m_jsonNamespace) : |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
436 new XmlSimpleAttribute(m_jsonPrefix, m_xmlnsNamespace, m_xmlnsPrefix, m_jsonNamespace) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
437 }; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
438 break; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
439 case JsonXmlReaderPosition.ValueElement: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
440 if (!m_isEmpty) { |
229 | 441 if (m_parser.ElementValue != null && !m_parser.ElementValue.Equals(string.Empty)) |
442 ValueNode(m_parser.ElementValue); | |
443 else | |
444 goto case JsonXmlReaderPosition.ValueContent; | |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
445 m_position = JsonXmlReaderPosition.ValueContent; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
446 return true; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
447 } else { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
448 m_position = JsonXmlReaderPosition.ValueEndElement; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
449 break; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
450 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
451 case JsonXmlReaderPosition.ValueContent: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
452 EndElementNode(m_jsonValueName, m_jsonNamespace); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
453 m_position = JsonXmlReaderPosition.ValueEndElement; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
454 return true; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
455 case JsonXmlReaderPosition.Eof: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
456 case JsonXmlReaderPosition.Closed: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
457 case JsonXmlReaderPosition.Error: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
458 return false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
459 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
460 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
461 while (m_parser.Read()) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
462 var jsonName = m_nameTable.Add(m_parser.ElementName); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
463 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
464 switch (m_parser.ElementType) { |
228 | 465 case JsonElementType.BeginObject: |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
466 if (!EnterJsonObject(jsonName, out elementName)) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
467 continue; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
468 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
469 m_position = JsonXmlReaderPosition.BeginObject; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
470 ElementNode(elementName, m_jsonNamespace, elementAttrs, false); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
471 break; |
228 | 472 case JsonElementType.EndObject: |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
473 if (!LeaveJsonScope(out elementName)) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
474 continue; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
475 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
476 m_position = JsonXmlReaderPosition.EndObject; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
477 EndElementNode(elementName, m_jsonNamespace); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
478 break; |
228 | 479 case JsonElementType.BeginArray: |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
480 if (!EnterJsonArray(jsonName, out elementName)) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
481 continue; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
482 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
483 m_position = JsonXmlReaderPosition.BeginArray; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
484 ElementNode(elementName, m_jsonNamespace, elementAttrs, false); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
485 break; |
228 | 486 case JsonElementType.EndArray: |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
487 if (!LeaveJsonScope(out elementName)) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
488 continue; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
489 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
490 m_position = JsonXmlReaderPosition.EndArray; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
491 EndElementNode(elementName, m_jsonNamespace); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
492 break; |
228 | 493 case JsonElementType.Value: |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
494 if (!VisitJsonValue(jsonName, out m_jsonValueName)) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
495 continue; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
496 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
497 m_position = JsonXmlReaderPosition.ValueElement; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
498 if (m_parser.ElementValue == null) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
499 // generate empty element with xsi:nil="true" attribute |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
500 ElementNode( |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
501 m_jsonValueName, |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
502 m_jsonNamespace, |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
503 new[] { |
236 | 504 new XmlSimpleAttribute("nil", m_xsiNamespace, m_xsiPrefix, "true") |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
505 }, |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
506 true |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
507 ); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
508 else |
229 | 509 ElementNode(m_jsonValueName, m_jsonNamespace, elementAttrs, m_parser.ElementValue.Equals(string.Empty)); |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
510 break; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
511 default: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
512 throw new Exception($"Unexpected JSON element {m_parser.ElementType}: {m_parser.ElementName}"); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
513 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
514 return true; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
515 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
516 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
517 m_position = JsonXmlReaderPosition.Eof; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
518 return false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
519 } catch { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
520 m_position = JsonXmlReaderPosition.Error; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
521 throw; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
522 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
523 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
524 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
525 void SaveJsonName() { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
526 m_jsonNameStack.Push(new JsonContext { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
527 skip = m_jsonSkip, |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
528 localName = m_jsonLocalName |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
529 }); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
530 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
531 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
532 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
533 bool EnterJsonObject(string name, out string elementName) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
534 SaveJsonName(); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
535 m_jsonSkip = false; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
536 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
537 if (string.IsNullOrEmpty(name)) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
538 if (m_jsonNameStack.Count != 1 && !m_jsonFlattenArrays) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
539 m_jsonLocalName = m_jsonArrayItemName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
540 } else { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
541 m_jsonLocalName = name; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
542 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
543 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
544 elementName = m_jsonLocalName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
545 return true; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
546 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
547 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
548 /// <summary> |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
549 /// Called when JSON parser visits BeginArray ('[') element. |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
550 /// </summary> |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
551 /// <param name="name">Optional property name if the array is the member of an object</param> |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
552 /// <returns>true if element should be emited, false otherwise</returns> |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
553 bool EnterJsonArray(string name, out string elementName) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
554 SaveJsonName(); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
555 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
556 if (string.IsNullOrEmpty(name)) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
557 // m_jsonNameStack.Count == 1 means the root node |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
558 if (m_jsonNameStack.Count != 1 && !m_jsonFlattenArrays) |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
559 m_jsonLocalName = m_jsonArrayItemName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
560 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
561 m_jsonSkip = false; // we should not flatten arrays inside arrays or in the document root |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
562 } else { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
563 m_jsonLocalName = name; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
564 m_jsonSkip = m_jsonFlattenArrays; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
565 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
566 elementName = m_jsonLocalName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
567 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
568 return !m_jsonSkip; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
569 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
570 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
571 bool VisitJsonValue(string name, out string elementName) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
572 if (string.IsNullOrEmpty(name)) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
573 // m_jsonNameStack.Count == 0 means that JSON document consists from simple value |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
574 elementName = (m_jsonNameStack.Count == 0 || m_jsonFlattenArrays) ? m_jsonLocalName : m_jsonArrayItemName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
575 } else { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
576 elementName = name; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
577 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
578 return true; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
579 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
580 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
581 bool LeaveJsonScope(out string elementName) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
582 elementName = m_jsonLocalName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
583 var skip = m_jsonSkip; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
584 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
585 var prev = m_jsonNameStack.Pop(); |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
586 m_jsonLocalName = prev.localName; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
587 m_jsonSkip = prev.skip; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
588 |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
589 return !skip; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
590 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
591 |
264 | 592 protected override void Dispose(bool disposing) { |
593 if (disposing) | |
594 Safe.Dispose(m_parser); | |
595 base.Dispose(true); | |
596 } | |
597 | |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
598 public override string ToString() { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
599 switch (NodeType) { |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
600 case XmlNodeType.Element: |
236 | 601 return $"<{Name} {string.Join(" ", (m_attributes ?? new XmlSimpleAttribute[0]).Select(x => $"{x.Prefix}{(string.IsNullOrEmpty(x.Prefix) ? "" : ":")}{x.QName.Name}='{x.Value}'"))} {(IsEmptyElement ? "/" : "")}>"; |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
602 case XmlNodeType.Attribute: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
603 return $"@{Name}"; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
604 case XmlNodeType.Text: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
605 return $"{Value}"; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
606 case XmlNodeType.CDATA: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
607 return $"<![CDATA[{Value}]]>"; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
608 case XmlNodeType.EntityReference: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
609 return $"&{Name};"; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
610 case XmlNodeType.EndElement: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
611 return $"</{Name}>"; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
612 default: |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
613 return $".{NodeType} {Name} {Value}"; |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
614 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
615 } |
264 | 616 |
617 #region static methods | |
618 | |
619 public static JsonXmlReader CreateJsonXmlReader(TextReader textReader, JsonXmlReaderOptions options = null) { | |
620 var jsonReader = JsonReader.Create(textReader); | |
621 return new JsonXmlReader(jsonReader, options); | |
622 } | |
623 | |
624 public static JsonXmlReader CreateJsonXmlReader(Stream stream, JsonXmlReaderOptions options = null) { | |
625 var jsonReader = JsonReader.Create(stream); | |
626 return new JsonXmlReader(jsonReader, options); | |
627 } | |
628 | |
629 public static JsonXmlReader CreateJsonXmlReader(string file, JsonXmlReaderOptions options = null) { | |
630 var jsonReader = JsonReader.Create(file); | |
631 return new JsonXmlReader(jsonReader, options); | |
632 } | |
633 | |
634 #endregion | |
227
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
635 } |
8d5de4eb9c2c
Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff
changeset
|
636 } |