Add implicit operators to JSONValue

master
Harald Wolff 2019-12-13 15:34:31 +01:00
parent f90b9588e2
commit d8c313c14c
1 changed files with 6 additions and 0 deletions

View File

@ -9,6 +9,7 @@
// **/
using System;
using System.Collections.Generic;
using ln.json.mapping;
namespace ln.json
{
public enum JSONValueType
@ -41,5 +42,10 @@ namespace ln.json
}
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);
}
}