MCPcopy Create free account
hub / github.com/boostorg/json / main

Function main

example/validate.cpp:98–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98int
99main(int argc, char** argv)
100{
101 if(argc != 2)
102 {
103 std::cerr <<
104 "Usage: validate <filename>"
105 << std::endl;
106 return EXIT_FAILURE;
107 }
108
109 try
110 {
111 // Read the file into a string
112 auto const s = read_file( argv[1] );
113
114 // See if the string is valid JSON
115 auto const valid = validate( s );
116
117 // Print the result
118 if( valid )
119 std::cout << argv[1] << " contains a valid JSON\n";
120 else
121 std::cout << argv[1] << " does not contain a valid JSON\n";
122 }
123 catch(std::exception const& e)
124 {
125 std::cerr <<
126 "Caught exception: "
127 << e.what() << std::endl;
128 return EXIT_FAILURE;
129 }
130
131 return EXIT_SUCCESS;
132}
133
134// end::example_validate[]

Callers

nothing calls this directly

Calls 3

read_fileFunction · 0.85
validateFunction · 0.70
whatMethod · 0.45

Tested by

no test coverage detected