Add implicit operators to JSONValue
parent
f90b9588e2
commit
d8c313c14c
|
@ -9,6 +9,7 @@
|
||||||
// **/
|
// **/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using ln.json.mapping;
|
||||||
namespace ln.json
|
namespace ln.json
|
||||||
{
|
{
|
||||||
public enum JSONValueType
|
public enum JSONValueType
|
||||||
|
@ -41,5 +42,10 @@ namespace ln.json
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => throw new NotImplementedException();
|
public override string ToString() => throw new NotImplementedException();
|
||||||
|
|
||||||
|
public static implicit operator JSONValue(String text) => new JSONString(text);
|
||||||
|
public static implicit operator JSONValue(bool b) => b ? (JSONValue)JSONTrue.Instance : (JSONValue)JSONFalse.Instance;
|
||||||
|
public static implicit operator JSONValue(int i) => new JSONNumber(i);
|
||||||
|
public static implicit operator JSONValue(double d) => new JSONNumber(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue