forked from ln-dotnet/ln.json
JSONValue.ToNative() added
parent
0140149fe0
commit
c1725c2a18
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Reflection;
|
|
||||||
namespace ln.json
|
namespace ln.json
|
||||||
{
|
{
|
||||||
public class JSONNumber : JSONValue
|
public class JSONNumber : JSONValue
|
||||||
|
@ -8,6 +7,13 @@ namespace ln.json
|
||||||
public Decimal Decimal => decValue;
|
public Decimal Decimal => decValue;
|
||||||
readonly decimal decValue;
|
readonly decimal decValue;
|
||||||
|
|
||||||
|
public override object ToNative()
|
||||||
|
{
|
||||||
|
if (Decimal.Ceiling(decValue).Equals(Decimal.Floor(decValue)))
|
||||||
|
return (long)decValue;
|
||||||
|
return (double)decValue;
|
||||||
|
}
|
||||||
|
|
||||||
public JSONNumber(int i)
|
public JSONNumber(int i)
|
||||||
: this((long)i) { }
|
: this((long)i) { }
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace ln.json
|
||||||
};
|
};
|
||||||
|
|
||||||
public string Value { get; private set; }
|
public string Value { get; private set; }
|
||||||
|
public override object ToNative() => Value;
|
||||||
|
|
||||||
public JSONString(String value)
|
public JSONString(String value)
|
||||||
:base(JSONValueType.STRING)
|
:base(JSONValueType.STRING)
|
||||||
|
|
|
@ -22,6 +22,8 @@ namespace ln.json
|
||||||
public virtual bool HasChildren => false;
|
public virtual bool HasChildren => false;
|
||||||
public virtual IEnumerable<JSONValue> Children => throw new NotSupportedException();
|
public virtual IEnumerable<JSONValue> Children => throw new NotSupportedException();
|
||||||
|
|
||||||
|
public virtual object ToNative() => throw new NotImplementedException();
|
||||||
|
|
||||||
public JSONValue(JSONValueType valueType)
|
public JSONValue(JSONValueType valueType)
|
||||||
{
|
{
|
||||||
ValueType = valueType;
|
ValueType = valueType;
|
||||||
|
|
Loading…
Reference in New Issue