Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
021417c029 | ||
|
|
853958acda |
@@ -0,0 +1,31 @@
|
|||||||
|
This is free and unencumbered software released into the public domain.
|
||||||
|
|
||||||
|
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||||
|
distribute this software, either in source code form or as a compiled
|
||||||
|
binary, for any purpose, commercial or non-commercial, and by any
|
||||||
|
means.
|
||||||
|
|
||||||
|
In jurisdictions that recognize copyright laws, the author or authors
|
||||||
|
of this software dedicate any and all copyright interest in the
|
||||||
|
software to the public domain. We make this dedication for the benefit
|
||||||
|
of the public at large and to the detriment of our heirs and
|
||||||
|
successors. We intend this dedication to be an overt act of
|
||||||
|
relinquishment in perpetuity of all present and future rights to this
|
||||||
|
software under copyright law.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
For more information, please refer to <http://unlicense.org/>
|
||||||
|
|
||||||
|
Thank you for reading this notice. Following the tradition of other public
|
||||||
|
domain projects, here's a blessing:
|
||||||
|
|
||||||
|
May you find forgiveness for yourself and forgive others.
|
||||||
|
May you experience and share the gift of unconditional love.
|
||||||
|
May you see light, wherever the illusion of darkness appears.
|
||||||
+47
-47
@@ -1,43 +1,43 @@
|
|||||||
#region Header
|
#region Header
|
||||||
/**
|
/**
|
||||||
* JsonWriter.cs
|
* JsonWriter.cs
|
||||||
* Stream-like facility to output JSON text.
|
* Stream-like facility to output JSON text.
|
||||||
*
|
*
|
||||||
* The authors disclaim copyright to this source code. For more details, see
|
* The authors disclaim copyright to this source code. For more details, see
|
||||||
* the COPYING file included with this distribution.
|
* the COPYING file included with this distribution.
|
||||||
**/
|
**/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
namespace LitJson
|
namespace LitJson
|
||||||
{
|
{
|
||||||
internal enum Condition
|
internal enum Condition
|
||||||
{
|
{
|
||||||
InArray,
|
InArray,
|
||||||
InObject,
|
InObject,
|
||||||
NotAProperty,
|
NotAProperty,
|
||||||
Property,
|
Property,
|
||||||
Value
|
Value
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class WriterContext
|
internal class WriterContext
|
||||||
{
|
{
|
||||||
public Int32 Count;
|
public Int32 Count;
|
||||||
public Boolean InArray;
|
public Boolean InArray;
|
||||||
public Boolean InObject;
|
public Boolean InObject;
|
||||||
public Boolean ExpectingValue;
|
public Boolean ExpectingValue;
|
||||||
public Int32 Padding;
|
public Int32 Padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class JsonWriter {
|
public class JsonWriter {
|
||||||
#region Fields
|
#region Fields
|
||||||
private static readonly NumberFormatInfo number_format;
|
private static readonly NumberFormatInfo number_format;
|
||||||
|
|
||||||
private WriterContext context;
|
private WriterContext context;
|
||||||
@@ -51,10 +51,10 @@ namespace LitJson
|
|||||||
private Boolean validate;
|
private Boolean validate;
|
||||||
private Boolean lower_case_properties;
|
private Boolean lower_case_properties;
|
||||||
private TextWriter writer;
|
private TextWriter writer;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
public Int32 IndentValue {
|
public Int32 IndentValue {
|
||||||
get { return this.indent_value; }
|
get { return this.indent_value; }
|
||||||
set {
|
set {
|
||||||
@@ -81,10 +81,10 @@ namespace LitJson
|
|||||||
get { return this.lower_case_properties; }
|
get { return this.lower_case_properties; }
|
||||||
set { this.lower_case_properties = value; }
|
set { this.lower_case_properties = value; }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
static JsonWriter() {
|
static JsonWriter() {
|
||||||
number_format = NumberFormatInfo.InvariantInfo;
|
number_format = NumberFormatInfo.InvariantInfo;
|
||||||
}
|
}
|
||||||
@@ -105,10 +105,10 @@ namespace LitJson
|
|||||||
|
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Private Methods
|
#region Private Methods
|
||||||
private void DoValidation(Condition cond) {
|
private void DoValidation(Condition cond) {
|
||||||
if (!this.context.ExpectingValue) {
|
if (!this.context.ExpectingValue) {
|
||||||
this.context.Count++;
|
this.context.Count++;
|
||||||
@@ -282,7 +282,7 @@ namespace LitJson
|
|||||||
this.indentation -= this.indent_value;
|
this.indentation -= this.indent_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
public override String ToString() {
|
public override String ToString() {
|
||||||
@@ -449,7 +449,7 @@ namespace LitJson
|
|||||||
this.context.Padding = propertyName.Length;
|
this.context.Padding = propertyName.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Int32 i = this.context.Padding - propertyName.Length;
|
for (Int32 i = this.context.Padding - propertyName.Length;
|
||||||
i >= 0; i--) {
|
i >= 0; i--) {
|
||||||
this.writer.Write(' ');
|
this.writer.Write(' ');
|
||||||
}
|
}
|
||||||
@@ -461,5 +461,5 @@ namespace LitJson
|
|||||||
|
|
||||||
this.context.ExpectingValue = true;
|
this.context.ExpectingValue = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user