In the current implementation, this is not possible.
So, I added new types:
public enum JSONBinaryTag
{
Array = 1,
Class = 2,
Value = 3,
IntValue = 4,
DoubleValue = 5,
BoolValue = 6,
FloatValue = 7,
LongValue = 8,
String = 9, // <-- new
Number = 10 // <-- new
}
And add type checking in JSONData:
public class JSONData : JSONNode{
static Regex m_Regex = new Regex(@"^[0-9]*(?:\.[0-9]*)?$");
private JSONBinaryTag m_Type = JSONBinaryTag.String;
private string m_Data;
public override string Value {
get { return m_Data; }
set { m_Data = value; }
}
public JSONData(string aData){
m_Data = aData;
if (m_Regex.IsMatch(m_Data))
m_Type = JSONBinaryTag.Number;
else
m_Type = JSONBinaryTag.String;
}
[...]
}
And changed the method toString():
public override string ToString(){
if (m_Type == JSONBinaryTag.String)
return "\"" + Escape(m_Data) + "\"";
else
return Escape(m_Data);
}
Now int, float, doubleit will be added without the number ". And it will look something like this:{"attr" : 4}
source
share