libmir/mir-ion

deserializeJson not supporting `@serdeProxy!JsonAlgebraic`

WebFreak001 opened this issue · 0 comments

since #17 deserializeJson (not deserializeDynamicJson) works with JsonAlgebraic, however it seems when wrapping it in a proxy struct and using @serdeProxy!JsonAlgebraic it doesn't work as expected:

unittest
{
	import mir.serde;
	import mir.algebraic_alias.json;
	import mir.ser.json : serializeJson;
	import mir.deser.json : deserializeJson;
	import std.conv : to;

	@serdeFallbackStruct
	@serdeProxy!JsonAlgebraic
	struct SerdeTest
	{
		JsonAlgebraic value;
	}

	StringMap!JsonAlgebraic object;
	object["foo"] = JsonAlgebraic("bar");

	SerdeTest test = SerdeTest(JsonAlgebraic(object));

	assert(test.serializeJson == `{"foo":"bar"}`);

	assert(test.serializeJson.deserializeJson!SerdeTest == test,
		test.serializeJson.deserializeJson!SerdeTest.to!string ~ " != "
		~ test.to!string);
}

fails with:

bug.d(23): SerdeTest([]) != SerdeTest(["foo": bar])

using deserializeDynamicJson instead of deserializeJson works as expected.