Advertisement
Viraax

Untitled

Mar 5th, 2021
628
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. // JSON-Like structure
  2.  
  3. typedef std::vector<std::any> Array;
  4. typedef std::unordered_map<std::string, std::any> Object;
  5.  
  6. std::any tableau = Array({ 25, "élément" });
  7. std::any objet = Object({
  8.     {
  9.         "omfg", tableau,
  10.     },
  11.     {
  12.         "bar", 6,
  13.     },
  14.     {
  15.         "baz", Object({
  16.             {"foo", 2}
  17.         })
  18.     }
  19. });
  20.  
  21. std::cout << (tableau.type() == typeid(Array)) << std::endl;
  22. std::cout << (objet.type() == typeid(Object)) << std::endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement