Skip to content

Can't have a json type as a property in an arbitrary type #2078

Closed
@TheOnlyArtz

Description

I'm trying to have a struct which can old json type as one of it's properties and it throws an error, for some reason.

namespace DataSerialization
{
	struct GeneralResponse
	{
		int op;
		json d;
	};

	void from_json(const json& j, const GeneralResponse& response)
	{
		j.at("op").get_to(response.op);
               // ERROR HERE
		j.at("d").get_to(response.d);
	}

	void to_json(json& j, const GeneralResponse& response)
	{
		j = json{ {"op", response.op}, {"d", response.d} };
	}
}

image

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions