annotate Implab/Xml/JsonXmlReader.cs @ 229:5f7a3e1d32b9 v2

JsonXmlReader performance tuning JsonScanner now operates strings and doesn't parses number and literals. Added SerializationHelpers to common serialize/deserialize operations
author cin
date Tue, 12 Sep 2017 19:07:42 +0300
parents 6fa235c5a760
children 302ca905c19e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 227
diff changeset
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;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
5 using System.Linq;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
6 using System.Xml;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
7
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
8 namespace Implab.Xml {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
9 public class JsonXmlReader : XmlReader {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
10 struct JsonContext {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
11 public string localName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
12 public bool skip;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
13 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
14
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
15 JsonReader m_parser;
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
16 JsonXmlReaderOptions m_options;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
17 JsonXmlReaderPosition m_position = JsonXmlReaderPosition.Initial;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
18 XmlNameTable m_nameTable;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
19
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
20 readonly string m_jsonRootName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
21 readonly string m_jsonNamespace;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
22 readonly string m_jsonPrefix;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
23 readonly bool m_jsonFlattenArrays;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
24 readonly string m_jsonArrayItemName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
25
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
26 string m_jsonLocalName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
27 string m_jsonValueName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
28 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
29
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
30 readonly Stack<JsonContext> m_jsonNameStack = new Stack<JsonContext>();
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
31
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
32 XmlQualifiedName m_elementQName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
33 string m_elementPrefix;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
34 int m_elementDepth;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
35 bool m_elementIsEmpty;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
36
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
37 XmlQualifiedName m_qName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
38 string m_prefix;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
39 int m_xmlDepth;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
40
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
41 XmlSimpleAttribute[] m_attributes;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
42 object m_value;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
43 bool m_isEmpty;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
44
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
45 XmlNodeType m_nodeType = XmlNodeType.None;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
46
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
47 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
48 int m_currentAttribute;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
49 bool m_currentAttributeRead;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
50
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 XmlNameContext m_context;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
53
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
54 readonly string m_xmlnsPrefix;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
55 readonly string m_xmlnsNamespace;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
56 readonly string m_xsiPrefix;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
57 readonly string m_xsiNamespace;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
58
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
59
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
60 public JsonXmlReader(JsonReader parser, JsonXmlReaderOptions options) {
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
61 Safe.ArgumentNotNull(parser, nameof(parser));
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
62 m_parser = parser;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
63
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
64 m_options = options ?? new JsonXmlReaderOptions();
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
65
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
66 m_jsonFlattenArrays = m_options.FlattenArrays;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
67 m_nameTable = m_options.NameTable ?? new NameTable();
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
68
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
69 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
70 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
71 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
72 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
73 m_xmlnsPrefix = m_nameTable.Add(XmlNameContext.XmlnsPrefix);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
74 m_xmlnsNamespace = m_nameTable.Add(XmlNameContext.XmlnsNamespace);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
75 m_xsiPrefix = m_nameTable.Add(XmlNameContext.XsiPrefix);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
76 m_xsiNamespace = m_nameTable.Add(XmlNameContext.XsiNamespace);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
77
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
78 // TODO validate m_jsonRootName, m_jsonArrayItemName
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
79
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
80 m_context = new XmlNameContext(null, 0);
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
81 }
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 public override int AttributeCount {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
84 get {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
85 return m_attributes == null ? 0 : m_attributes.Length;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
86 }
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 public override string BaseURI {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
90 get {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
91 return string.Empty;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
92 }
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 public override int Depth {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
96 get {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
97 return m_xmlDepth;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
98 }
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 public override bool EOF {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
102 get {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
103 return m_position == JsonXmlReaderPosition.Eof;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
104 }
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 public override bool IsEmptyElement {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
108 get { return m_isEmpty; }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
109 }
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 public override string LocalName {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
113 get {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
114 return m_qName.Name;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
115 }
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 public override string NamespaceURI {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
119 get {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
120 return m_qName.Namespace;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
121 }
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 public override XmlNameTable NameTable {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
125 get {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
126 return m_nameTable;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
127 }
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 public override XmlNodeType NodeType {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
131 get {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
132 return m_nodeType;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
133 }
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 public override string Prefix {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
137 get {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
138 return m_prefix;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
139 }
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 public override ReadState ReadState {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
143 get {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
144 switch (m_position) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
145 case JsonXmlReaderPosition.Initial:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
146 return ReadState.Initial;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
147 case JsonXmlReaderPosition.Eof:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
148 return ReadState.EndOfFile;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
149 case JsonXmlReaderPosition.Closed:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
150 return ReadState.Closed;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
151 case JsonXmlReaderPosition.Error:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
152 return ReadState.Error;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
153 default:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
154 return ReadState.Interactive;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
155 };
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 public override string Value {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
160 get {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
161 return ConvertValueToString(m_value);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
162 }
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
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
165 static string ConvertValueToString(object value) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
166 if (value == null)
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
167 return string.Empty;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
168
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
169 switch (Convert.GetTypeCode(value)) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
170 case TypeCode.Double:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
171 return ((double)value).ToString(CultureInfo.InvariantCulture);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
172 case TypeCode.String:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
173 return (string)value;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
174 case TypeCode.Boolean:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
175 return (bool)value ? "true" : "false";
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
176 default:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
177 return value.ToString();
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
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
181 public override string GetAttribute(int i) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
182 Safe.ArgumentInRange(i, 0, AttributeCount - 1, nameof(i));
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
183 return ConvertValueToString(m_attributes[i].Value);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
184 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
185
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
186 public override string GetAttribute(string name) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
187 if (m_attributes == null)
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
188 return null;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
189 var qName = m_context.Resolve(name);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
190 var attr = Array.Find(m_attributes, x => x.QName == qName);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
191 var value = ConvertValueToString(attr?.Value);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
192 return value == string.Empty ? null : value;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
193 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
194
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
195 public override string GetAttribute(string name, string namespaceURI) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
196 if (m_attributes == null)
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
197 return null;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
198 var qName = new XmlQualifiedName(name, namespaceURI);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
199 var attr = Array.Find(m_attributes, x => x.QName == qName);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
200 var value = ConvertValueToString(attr?.Value);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
201 return value == string.Empty ? null : value;
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
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
204 public override string LookupNamespace(string prefix) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
205 return m_context.ResolvePrefix(prefix);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
206 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
207
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
208 public override bool MoveToAttribute(string name) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
209 if (m_attributes == null || m_attributes.Length == 0)
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
210 return false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
211
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
212 var qName = m_context.Resolve(name);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
213 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
214 if (index >= 0) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
215 MoveToAttributeImpl(index);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
216 return true;
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 return false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
219 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
220
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
221 public override bool MoveToAttribute(string name, string ns) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
222 if (m_attributes == null || m_attributes.Length == 0)
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
223 return false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
224
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
225 var qName = m_context.Resolve(name);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
226 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
227 if (index >= 0) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
228 MoveToAttributeImpl(index);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
229 return true;
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 return false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
232 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
233
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
234 void MoveToAttributeImpl(int i) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
235 if (!m_isAttribute) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
236 m_elementQName = m_qName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
237 m_elementDepth = m_xmlDepth;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
238 m_elementPrefix = m_prefix;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
239 m_elementIsEmpty = m_isEmpty;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
240 m_isAttribute = true;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
241 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
242
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
243 var attr = m_attributes[i];
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
244
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
245
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
246 m_currentAttribute = i;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
247 m_currentAttributeRead = false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
248 m_nodeType = XmlNodeType.Attribute;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
249
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
250 m_xmlDepth = m_elementDepth + 1;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
251 m_qName = attr.QName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
252 m_value = attr.Value;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
253 m_prefix = attr.Prefix;
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
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
256 public override bool MoveToElement() {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
257 if (m_isAttribute) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
258 m_value = null;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
259 m_nodeType = XmlNodeType.Element;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
260 m_xmlDepth = m_elementDepth;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
261 m_prefix = m_elementPrefix;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
262 m_qName = m_elementQName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
263 m_isEmpty = m_elementIsEmpty;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
264 m_isAttribute = false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
265 return true;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
266 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
267 return false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
268 }
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 public override bool MoveToFirstAttribute() {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
271 if (m_attributes != null && m_attributes.Length > 0) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
272 MoveToAttributeImpl(0);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
273 return true;
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 return false;
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
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
278 public override bool MoveToNextAttribute() {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
279 if (m_isAttribute) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
280 var next = m_currentAttribute + 1;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
281 if (next < AttributeCount) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
282 MoveToAttributeImpl(next);
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 return false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
286 } else {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
287 return MoveToFirstAttribute();
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 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
291
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
292 public override bool ReadAttributeValue() {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
293 if (!m_isAttribute || m_currentAttributeRead)
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
294 return false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
295
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
296 ValueNode(m_attributes[m_currentAttribute].Value);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
297 m_currentAttributeRead = true;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
298 return true;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
299 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
300
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
301 public override void ResolveEntity() {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
302 /* do nothing */
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
303 }
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 /// <summary>
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
306 /// 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
307 /// </summary>
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
308 /// <returns></returns>
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
309 public bool IsSibling() {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
310 switch (m_nodeType) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
311 case XmlNodeType.None: // start document
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
312 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
313 return false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
314 case XmlNodeType.Element:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
315 // 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
316 return m_isEmpty;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
317 default:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
318 return true;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
319 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
320 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
321
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
322 void ValueNode(object value) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
323 if (!IsSibling()) // the node is nested
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
324 m_xmlDepth++;
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 m_qName = XmlQualifiedName.Empty;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
327 m_nodeType = XmlNodeType.Text;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
328 m_prefix = string.Empty;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
329 m_value = value;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
330 m_isEmpty = false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
331 m_attributes = null;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
332 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
333
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
334 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
335 if (!IsSibling()) // the node is nested
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
336 m_xmlDepth++;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
337
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
338 var context = m_context;
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
339 List<XmlSimpleAttribute> definedAttrs = null;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
340
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
341 // define new namespaces
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
342 if (attrs != null) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
343 foreach (var attr in attrs) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
344 if (attr.QName.Name == "xmlns") {
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
345 if (context == m_context)
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
346 context = new XmlNameContext(m_context, m_xmlDepth);
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
347 context.DefinePrefix(ConvertValueToString(attr.Value), string.Empty);
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
348 } else if (attr.Prefix == m_xmlnsPrefix) {
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
349 if (context == m_context)
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
350 context = new XmlNameContext(m_context, m_xmlDepth);
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
351 context.DefinePrefix(ConvertValueToString(attr.Value), attr.QName.Name);
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
352 } else {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
353 string attrPrefix;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
354 if (string.IsNullOrEmpty(attr.QName.Namespace))
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
355 continue;
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 // auto-define prefixes
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
358 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
359 // new namespace prefix added
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
360 attrPrefix = context.CreateNamespacePrefix(attr.QName.Namespace);
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
361 attr.Prefix = attrPrefix;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
362
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(attrPrefix, m_xmlnsNamespace, m_xmlnsPrefix, attr.QName.Namespace));
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 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
370 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
371
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
372 string p;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
373 // auto-define prefixes
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
374 if (!context.LookupNamespacePrefix(ns, out p)) {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
375 if (context == m_context)
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
376 context = new XmlNameContext(m_context, m_xmlDepth);
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
377 p = context.CreateNamespacePrefix(ns);
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
378 if (definedAttrs == null)
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
379 definedAttrs = new List<XmlSimpleAttribute>();
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
380
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
381 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
382 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
383
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
384 if (definedAttrs != null) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
385 if (attrs != null)
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
386 definedAttrs.AddRange(attrs);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
387 attrs = definedAttrs.ToArray();
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
388 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
389
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
390 if (!empty)
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
391 m_context = context;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
392
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
393 m_nodeType = XmlNodeType.Element;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
394 m_qName = new XmlQualifiedName(name, ns);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
395 m_prefix = p;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
396 m_value = null;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
397 m_isEmpty = empty;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
398 m_attributes = attrs;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
399 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
400
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
401 void EndElementNode(string name, string ns) {
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
402 if (IsSibling()) {
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
403 // closing the element which has children
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
404 m_xmlDepth--;
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
405 }
227
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 string p;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
408 if (!m_context.LookupNamespacePrefix(ns, out p))
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
409 throw new Exception($"Failed to lookup namespace '{ns}'");
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
410
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
411 if (m_context.Depth == m_xmlDepth)
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
412 m_context = m_context.ParentContext;
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
413
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
414 m_nodeType = XmlNodeType.EndElement;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
415 m_prefix = p;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
416 m_qName = new XmlQualifiedName(name, ns);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
417 m_value = null;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
418 m_attributes = null;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
419 m_isEmpty = false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
420 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
421
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
422 void XmlDeclaration() {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
423 if (!IsSibling()) // the node is nested
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
424 m_xmlDepth++;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
425 m_nodeType = XmlNodeType.XmlDeclaration;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
426 m_qName = new XmlQualifiedName("xml");
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
427 m_value = "version='1.0'";
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
428 m_prefix = string.Empty;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
429 m_attributes = null;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
430 m_isEmpty = false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
431 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
432
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
433 public override bool Read() {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
434 try {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
435 string elementName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
436 XmlSimpleAttribute[] elementAttrs = null;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
437 MoveToElement();
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
438
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
439 switch (m_position) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
440 case JsonXmlReaderPosition.Initial:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
441 m_jsonLocalName = m_jsonRootName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
442 m_jsonSkip = false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
443 XmlDeclaration();
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
444 m_position = JsonXmlReaderPosition.Declaration;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
445 return true;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
446 case JsonXmlReaderPosition.Declaration:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
447 elementAttrs = new[] {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
448 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
449 string.IsNullOrEmpty(m_jsonPrefix) ?
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
450 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
451 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
452 };
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
453 break;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
454 case JsonXmlReaderPosition.ValueElement:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
455 if (!m_isEmpty) {
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
456 if (m_parser.ElementValue != null && !m_parser.ElementValue.Equals(string.Empty))
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
457 ValueNode(m_parser.ElementValue);
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
458 else
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
459 goto case JsonXmlReaderPosition.ValueContent;
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
460 m_position = JsonXmlReaderPosition.ValueContent;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
461 return true;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
462 } else {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
463 m_position = JsonXmlReaderPosition.ValueEndElement;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
464 break;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
465 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
466 case JsonXmlReaderPosition.ValueContent:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
467 EndElementNode(m_jsonValueName, m_jsonNamespace);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
468 m_position = JsonXmlReaderPosition.ValueEndElement;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
469 return true;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
470 case JsonXmlReaderPosition.Eof:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
471 case JsonXmlReaderPosition.Closed:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
472 case JsonXmlReaderPosition.Error:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
473 return false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
474 }
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 while (m_parser.Read()) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
477 var jsonName = m_nameTable.Add(m_parser.ElementName);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
478
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
479 switch (m_parser.ElementType) {
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 227
diff changeset
480 case JsonElementType.BeginObject:
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
481 if (!EnterJsonObject(jsonName, out elementName))
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
482 continue;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
483
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
484 m_position = JsonXmlReaderPosition.BeginObject;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
485 ElementNode(elementName, m_jsonNamespace, elementAttrs, false);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
486 break;
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 227
diff changeset
487 case JsonElementType.EndObject:
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
488 if (!LeaveJsonScope(out elementName))
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
489 continue;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
490
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
491 m_position = JsonXmlReaderPosition.EndObject;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
492 EndElementNode(elementName, m_jsonNamespace);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
493 break;
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 227
diff changeset
494 case JsonElementType.BeginArray:
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
495 if (!EnterJsonArray(jsonName, out elementName))
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
496 continue;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
497
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
498 m_position = JsonXmlReaderPosition.BeginArray;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
499 ElementNode(elementName, m_jsonNamespace, elementAttrs, false);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
500 break;
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 227
diff changeset
501 case JsonElementType.EndArray:
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
502 if (!LeaveJsonScope(out elementName))
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
503 continue;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
504
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
505 m_position = JsonXmlReaderPosition.EndArray;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
506 EndElementNode(elementName, m_jsonNamespace);
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
507 break;
228
6fa235c5a760 Rewritten JsonScanner, JsonParser, fixed naming style
cin
parents: 227
diff changeset
508 case JsonElementType.Value:
227
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
509 if (!VisitJsonValue(jsonName, out m_jsonValueName))
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
510 continue;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
511
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
512 m_position = JsonXmlReaderPosition.ValueElement;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
513 if (m_parser.ElementValue == null)
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
514 // generate empty element with xsi:nil="true" attribute
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
515 ElementNode(
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
516 m_jsonValueName,
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
517 m_jsonNamespace,
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
518 new[] {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
519 new XmlSimpleAttribute("nil", m_xsiNamespace, m_xsiPrefix, true)
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
520 },
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
521 true
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 else
229
5f7a3e1d32b9 JsonXmlReader performance tuning
cin
parents: 228
diff changeset
524 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
525 break;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
526 default:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
527 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
528 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
529 return true;
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 m_position = JsonXmlReaderPosition.Eof;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
533 return false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
534 } catch {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
535 m_position = JsonXmlReaderPosition.Error;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
536 throw;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
537 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
538 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
539
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
540 void SaveJsonName() {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
541 m_jsonNameStack.Push(new JsonContext {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
542 skip = m_jsonSkip,
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
543 localName = m_jsonLocalName
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
544 });
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
545
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 bool EnterJsonObject(string name, out string elementName) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
549 SaveJsonName();
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
550 m_jsonSkip = false;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
551
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
552 if (string.IsNullOrEmpty(name)) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
553 if (m_jsonNameStack.Count != 1 && !m_jsonFlattenArrays)
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
554 m_jsonLocalName = m_jsonArrayItemName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
555 } else {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
556 m_jsonLocalName = name;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
557 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
558
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
559 elementName = m_jsonLocalName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
560 return true;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
561 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
562
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
563 /// <summary>
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
564 /// Called when JSON parser visits BeginArray ('[') element.
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
565 /// </summary>
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
566 /// <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
567 /// <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
568 bool EnterJsonArray(string name, out string elementName) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
569 SaveJsonName();
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 if (string.IsNullOrEmpty(name)) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
572 // m_jsonNameStack.Count == 1 means the root node
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
573 if (m_jsonNameStack.Count != 1 && !m_jsonFlattenArrays)
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
574 m_jsonLocalName = m_jsonArrayItemName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
575
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
576 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
577 } else {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
578 m_jsonLocalName = name;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
579 m_jsonSkip = m_jsonFlattenArrays;
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 elementName = m_jsonLocalName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
582
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
583 return !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
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
586 bool VisitJsonValue(string name, out string elementName) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
587 if (string.IsNullOrEmpty(name)) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
588 // 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
589 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
590 } else {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
591 elementName = name;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
592 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
593 return true;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
594 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
595
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
596 bool LeaveJsonScope(out string elementName) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
597 elementName = m_jsonLocalName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
598 var skip = m_jsonSkip;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
599
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
600 var prev = m_jsonNameStack.Pop();
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
601 m_jsonLocalName = prev.localName;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
602 m_jsonSkip = prev.skip;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
603
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
604 return !skip;
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
605 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
606
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
607 public override string ToString() {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
608 switch (NodeType) {
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
609 case XmlNodeType.Element:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
610 return $"<{Name} {string.Join(" ", (m_attributes ?? new XmlSimpleAttribute[0]).Select(x => $"{x.Prefix}{(string.IsNullOrEmpty(x.Prefix) ? "" : ":")}{x.QName.Name}='{ConvertValueToString(x.Value)}'"))} {(IsEmptyElement ? "/" : "")}>";
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
611 case XmlNodeType.Attribute:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
612 return $"@{Name}";
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
613 case XmlNodeType.Text:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
614 return $"{Value}";
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
615 case XmlNodeType.CDATA:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
616 return $"<![CDATA[{Value}]]>";
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
617 case XmlNodeType.EntityReference:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
618 return $"&{Name};";
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
619 case XmlNodeType.EndElement:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
620 return $"</{Name}>";
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
621 default:
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
622 return $".{NodeType} {Name} {Value}";
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
623 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
624 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
625 }
8d5de4eb9c2c Reimplemented JsonXmlReader, added support for null values: JSON null values are
cin
parents:
diff changeset
626 }