Giter Site home page Giter Site logo

String Vector to Json::array about json11 HOT 3 CLOSED

dropbox avatar dropbox commented on May 10, 2024
String Vector to Json::array

from json11.

Comments (3)

hassanfarid avatar hassanfarid commented on May 10, 2024 1

I found a solution myself:

Use Json::array constructor,
Json j = Json::array({vector_of_string_with_json_formatted_string});
cout<<j.dump();

this would result in string:
"[[{"key":"value"}, {"key":"value"}]]"

so then you can use below code to get required object format,

cout<<j[0].dump();

from json11.

j4cbo avatar j4cbo commented on May 10, 2024

Iterate through the vector and use Json::parse on each string, build up a vector<Json>, then convert the result to Json

from json11.

hassanfarid avatar hassanfarid commented on May 10, 2024

I forgot the solution that I found earlier, and found it useful finding it here. Thanks myself. :)

from json11.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.