예제 #1
0
        public string WriteJsonString()
        {
            StartWriteObject();
            var stringEnumerator = _jsonProperties.GetStringPropertiesEnumerator();
            var objcetEnumerator = _jsonProperties.GetObjectPropertiesEnumerator();

            if (stringEnumerator.MoveNext() == false)
            {
                return("");
            }

            do
            {
                AddOneProperty(stringEnumerator.Current.Key, stringEnumerator.Current.Value);
            } while (stringEnumerator.MoveNext());

            if (objcetEnumerator.MoveNext() == false)
            {
                return(_stringBuilder.ToString());
            }

            do
            {
                AddOneProperty(objcetEnumerator.Current.Key, objcetEnumerator.Current.Value);
            } while (objcetEnumerator.MoveNext());

            EndWriteObject();

            return(_stringBuilder.ToString());
        }
예제 #2
0
        private void AddOneProperty(string name, JsonProperties jsonProperties)
        {
            if (name == null || name == "")
            {
                return;
            }
            var enumerator = jsonProperties.GetStringPropertiesEnumerator();

            if (enumerator.MoveNext() == false)
            {
                return;
            }

            _stringBuilder.AppendFormat("\"{0}\":", name);
            StartWriteObject();

            do
            {
                var current = enumerator.Current;
                AddOneProperty(current.Key, current.Value);
            } while (enumerator.MoveNext());

            EndWriteObject();
            _stringBuilder.Append(',');
        }