0

I wanna create various objects like this in c++ and use them as function parameters. Is it possible? How can I do that ?

example = {
   "name": "example_name",
   "values" : [{"key": "value"},{"key": "value"}, ...]
   "more_info": {"address": "some_text", "city": "some_city", ...},
};

example2 = {
   "code": "some_code",
   "attributes": [...],
   "creation_date" : "some_date",
};

some_func({"use_atribute": false, "send_message": true, "first_val": example, "second_val":  example2});

2
  • 1
    Not without a lot of effort. C++ is a strongly typed language and JavaScript is weakly typed. Commented Apr 26, 2020 at 7:13
  • 3
    You can get quit close to javascript objects witth a std::map (or std::unordered_map) with std::any as values. Commented Apr 26, 2020 at 7:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.