Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deserializeJson not supporting @serdeProxy!JsonAlgebraic #21

Open
WebFreak001 opened this issue Apr 25, 2022 · 0 comments
Open

deserializeJson not supporting @serdeProxy!JsonAlgebraic #21

WebFreak001 opened this issue Apr 25, 2022 · 0 comments

Comments

@WebFreak001
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant