cpp-redis/cpp_redis

Nested Array Data Output Formating & Extraction

NMS0 opened this issue · 0 comments

NMS0 commented

Hello,

I am trying to format output data within the fields portion of the XADD command. With the following commands:

const std::string session_name = "Data";

	client.xadd(session_name, "*", {{"Harry", "54"}, {"Jane", "41"}, {"Laura", "25"}, 
									{"Nicky", "36"}, {"Kevin", "32"}}, 
											[](cpp_redis::reply &reply) {

	});

	client.xrange(session_name, {"-", "+", 10}, [](cpp_redis::reply &reply){

		if(reply.is_array()) {
				for(const auto key : reply.as_array()) {
	 			     std::cout << key << std::endl;
		}
	});

client.sync_commit();

This is the current output:

1594282837961-0Harry54Jane41Kevin32Laura25Nicky36

I want to pass this information to another application but in a format that looks like this:

1594282837961-0 Harry 54 Jane 41 Kevin 32 Laura 25 Nicky 36

I have been trying multi dimensional vector manipulations to the code as I understand that this part of the output is a nested array within the default array response from redis. Nothing is working at the moment.

Can anyone help with this please?
Thanks.