added JSONMapper.Deserialize<T>(..), added JSONMapper.Deserialize(string..)
ln.build - build0.waldrennach.l--n.de build job pending
Details
ln.build - build0.waldrennach.l--n.de build job pending
Details
parent
492e232fa7
commit
02adec8cb8
|
@ -125,6 +125,16 @@ namespace ln.json.tests
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDeserialize()
|
||||||
|
{
|
||||||
|
Assert.IsTrue(JSONMapper.DefaultMapper.Deserialize("[\"A\",\"B\",\"C\"]", out string[] texts));
|
||||||
|
Assert.AreEqual(3, texts.Length);
|
||||||
|
Assert.AreEqual("A", texts[0]);
|
||||||
|
Assert.AreEqual("B", texts[1]);
|
||||||
|
Assert.AreEqual("C", texts[2]);
|
||||||
|
}
|
||||||
|
|
||||||
void TestPrimitiveMapping(object primitiveValue)
|
void TestPrimitiveMapping(object primitiveValue)
|
||||||
{
|
{
|
||||||
Type primitiveType = primitiveValue.GetType();
|
Type primitiveType = primitiveValue.GetType();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<Version>1.0.5</Version>
|
<Version>1.0.6</Version>
|
||||||
<Authors>Harald Wolff-Thobaben</Authors>
|
<Authors>Harald Wolff-Thobaben</Authors>
|
||||||
<Company>l--n.de</Company>
|
<Company>l--n.de</Company>
|
||||||
<Product>ln.json</Product>
|
<Product>ln.json</Product>
|
||||||
|
|
|
@ -182,6 +182,19 @@ namespace ln.json.mapping
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool Deserialize<T>(string jsonSource, out T v) => Deserialize(JSONParser.Parse(jsonSource), out v);
|
||||||
|
public virtual bool Deserialize<T>(JSONValue json, out T v)
|
||||||
|
{
|
||||||
|
if (Deserialize(json, typeof(T), out object o))
|
||||||
|
{
|
||||||
|
v = (T)o;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
v = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool Deserialize(string jsonSource, Type nativeType, out object o) => Deserialize(JSONParser.Parse(jsonSource), nativeType, out o);
|
||||||
public virtual bool Deserialize(JSONValue json, Type nativeType, out object o)
|
public virtual bool Deserialize(JSONValue json, Type nativeType, out object o)
|
||||||
{
|
{
|
||||||
o = null;
|
o = null;
|
||||||
|
|
Loading…
Reference in New Issue