C++ Json::meta()














































C++ Json::meta()



Json::meta()

In this article we will go through one of the Static Public Member Functions of Json Nlohmann library named meta().

Syntax:

          static basic_json nlohmann::basic_json::meta( )	

Return Value:

This function returns a Json Object with information about the library along with the version number and information on the compiler.
       
       key                             description   
   compiler                It gives the information on the compiler used.
   copyright               This is the copyright line for the library as string.
     name                   It specifies the name of the library as string.
   Platform                It specifies the currently used platform 
                                (e.g.,win32, linux, apple, unix)                               
       url                     It specifies the url of the object as string.
    version                 It gives the description about the version of the                                                                 library.

Example:

The given example demonstrates the usage of meta().
#include <iostream>
#include <iomanip>
#include <nlohmann/json.hpp>

using json = nlohmann::json;

int main()
{
std::cout << std::setw(4) << json::meta() << '\n';
}

Output:

{
"compiler": {
"c++": "201103",
"family": "gcc",
"version": "4.9.2"
},
"copyright": "(C) 2013-2017 Niels Lohmann",
"name": "JSON for Modern C++",
"platform": "win32",
"url": "https://github.com/nlohmann/json",
"version": {
"major": 3,
"minor": 7,
"patch": 3,
"string": "3.7.3"
}
}

Note : If an exception is thrown, there will not be any change to the Json value.



Comments