Skip to content

pointer to json parse vector #711

Description

@kessero

My main:

int main(int argc, char *argv[])
{
  // read a JSON file
  std::stringstream ss;
  std::ifstream i("filee.json");
  json j_complete = json::parse(i);
  std::vector < int > data_send_to_LED;
  for (int i =0; i<j_complete["tablica"].size(); i++){
    data_send_to_LED.push_back(j_complete["tablica"][i].get<int>());
  }
  for (int i =0; i<data_send_to_LED.size(); i++){
    cout <<"data send: "<< data_send_to_LED[i]<<endl;
  }
  json j_vec(data_send_to_LED);
  long int pv = j_vec.get_ptr<json::number_integer_t*>();
  cout << j_vec.size() << endl;
  cout << j_vec << endl;
  cout << pv << endl;
...
n = write(sockfd,pv, j_vec.size()+1);

In general I want to send the contents of the file.json file to the server which accepts data in json format.
J_vec shows - [192,0,0,1,0,0,1,0,84,76,126]
Pv.size shows 11 elements and this is OK
pv shows 0
and n returns bad address?
I can skip the vector in the program and send the data directly form file.

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

    solution: proposed fixa fix for the issue has been proposed and waits for confirmation

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions