You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PlumberUltimateAds/Assets/Scripts/SimpleJSON/JSONData.cs

108 lines
1.7 KiB
C#

3 months ago
/*
http://www.cgsoso.com/forum-211-1.html
CG Unity3d Unity3d VIP
CGSOSO CG
daily assets update for try.
U should buy the asset from home store if u use it in your project!
*/
using System.IO;
namespace SimpleJSON
{
public class JSONData : JSONNode
{
private string m_Data;
public override string Value
{
get
{
return m_Data;
}
set
{
m_Data = value;
}
}
public JSONData(string aData)
{
m_Data = aData;
}
public JSONData(float aData)
{
AsFloat = aData;
}
public JSONData(double aData)
{
AsDouble = aData;
}
public JSONData(bool aData)
{
AsBool = aData;
}
public JSONData(int aData)
{
AsInt = aData;
}
public override string ToString()
{
return "\"" + JSONNode.Escape(m_Data) + "\"";
}
public override string ToString(string aPrefix)
{
return "\"" + JSONNode.Escape(m_Data) + "\"";
}
public override void Serialize(BinaryWriter aWriter)
{
JSONData jSONData = new JSONData(string.Empty);
jSONData.AsInt = AsInt;
if (jSONData.m_Data == m_Data)
{
aWriter.Write((byte)4);
aWriter.Write(AsInt);
return;
}
jSONData.AsFloat = AsFloat;
if (jSONData.m_Data == m_Data)
{
aWriter.Write((byte)7);
aWriter.Write(AsFloat);
return;
}
jSONData.AsDouble = AsDouble;
if (jSONData.m_Data == m_Data)
{
aWriter.Write((byte)5);
aWriter.Write(AsDouble);
return;
}
jSONData.AsBool = AsBool;
if (jSONData.m_Data == m_Data)
{
aWriter.Write((byte)6);
aWriter.Write(AsBool);
}
else
{
aWriter.Write((byte)3);
aWriter.Write(m_Data);
}
}
}
}