L
L
Levingstone2021-02-22 14:28:16
JSON
Levingstone, 2021-02-22 14:28:16

How can I use a JavaScript object in c++?

Hello.
The question arose, how can I use a js object by casting it to json format if sent and used in a c ++ environment? Specifically, you need to read all the fields.

var msg = {
    type: "chtoto",
    text: "chtoto",
    ident: 1,
  };


What data structure will be for c++ and what should be done with the object after parsing?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2021-02-22
@Levingstone

Levingstone , If this is an arbitrary json, and not the nailed msg struct from the example, then the parsers will store some kind of tree where the vertices have key-names and links to data. The implementation of this tree is already as the parser decides. Take a ready-made library and see what it returns to you in the documentation.
If you want to parse this particular (msg) structure, then you may be able to turn json into a class in two strings and one int.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question