Skip to content

if first member is optional in struct, the json from map_struct_to_json is invalid, there is a unjustified comma appear in json #22

@darylwei

Description

@darylwei
detail::IterateOver::set_null =	[&] (const std::string& name)
	{
		if constexpr (debug)
		{
			std::cout
				<< "struct_mapping: map_struct_to_json.set_null: "
				<< name
				<< std::endl;
		}

		if (!hide_null)
		{
			if (!first_element)
			{
				json_data << ",";
			}

			if (!indent.empty())
			{
				json_data << "\n";
			}

			for (unsigned i = indent_count; i != 0; --i)
			{
				json_data << indent; 
			}

			if (name.empty())
			{
				json_data << "null";
			}
			else
			{
				json_data << "\"" << name << "\":";
				
				if (!indent.empty())
				{
					json_data << " ";
				}

				json_data << "null";
			}
                     first_element = false; 
		}

		//first_element = false;
	};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions