Skip to content

How to handle std::vector<std::uint8_t> #1930

Description

@ntoskrnl-exe

I have built my own sockets layer, which works for an application I am working on.

The response from the Send returns a "complex" type containing the following data

std::vector<std::string> headers;
std::vector<std::uint8_t> body;

The reason the complex type represents the body as vector of bytes is the api will also transfer binary data as well as JSON string data.

My problem is when I do HTTP post, my data is sent correctly to the server. It updates the database, and then returns to my client. In the response, there is JSON data. I am trying to work out how to construct a JSON "object" that I can call contains to query the structured information for the certain returned data.

I have tried

nlohman::json _json(_response.body);

but it appears unable to find the nodes when I query the using contains. I have manually tried converting the vector of bytes to a string and parsing that, to no available.

I guess what I am asking for, is what section of the help should I look at more closely, to find the solution.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: questionsolution: proposed fixa fix for the issue has been proposed and waits for confirmationstate: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updated

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions