#include <jsonclass.h>
|
| Json (string json="") |
|
int32_t | extract_contents (string json) |
|
int32_t | extract_members (string::iterator &begin, string::iterator &end, Object &members) |
|
int32_t | extract_values (string::iterator &begin, string::iterator &end, Array &values) |
|
int32_t | extract_string (string::iterator &bit, string::iterator &eit, string &ostring) |
|
int32_t | extract_name (string::iterator &bit, string::iterator &eit, string &name) |
|
int32_t | extract_value (string::iterator &bit, string::iterator &eit, Value &value) |
|
int32_t | extract_member (string::iterator &bit, string::iterator &eit, Member &value) |
|
int32_t | skip_character (string::iterator &bit, string::iterator &eit, const char character) |
|
int32_t | skip_to_character (string::iterator &bit, string::iterator &eit, string characters) |
|
int32_t | skip_white (string::iterator &bit, string::iterator &eit) |
|
|
string::iterator | begin |
|
string::iterator | end |
|
JSON Basic Types enum defining the basic types of value to be found in a JSON member
Enumerator |
---|
Undefined |
|
Null |
|
False |
|
True |
|
Number |
|
String |
|
Array |
|
Object |
|
map< string, Value > Object
Definition: jsonclass.h:47
vector< Value > Array
Definition: jsonclass.h:48
Cosmos::Support::Json::Json |
( |
string |
json = "" | ) |
|
int32_t extract_contents(string json)
Definition: jsonclass.cpp:16
int32_t Cosmos::Support::Json::extract_contents |
( |
string |
json | ) |
|
JSON Member elements Structure containing the 2 basic parts of a JSON member, plus some supporting information. JSON Object Complete JSON Object, containing both the string of characters and a heirarchical vector of values.
23 string::iterator
begin = json.begin();
24 string::iterator
end = json.end();
int32_t extract_members(string::iterator &begin, string::iterator &end, Object &members)
Definition: jsonclass.cpp:89
int iretn
Definition: rw_test.cpp:37
int32_t extract_values(string::iterator &begin, string::iterator &end, Array &values)
Definition: jsonclass.cpp:112
int32_t skip_character(string::iterator &bit, string::iterator &eit, const char character)
Definition: jsonclass.cpp:449
string::iterator begin
Definition: jsonclass.h:87
string Content
Definition: jsonclass.h:79
Type JType
Definition: jsonclass.h:80
Object ObjectContents
Definition: jsonclass.h:81
int32_t skip_to_character(string::iterator &bit, string::iterator &eit, string characters)
Definition: jsonclass.cpp:473
string::iterator end
Definition: jsonclass.h:88
Array ArrayContents
Definition: jsonclass.h:82
int32_t skip_white(string::iterator &bit, string::iterator &eit)
Definition: jsonclass.cpp:433
int32_t Cosmos::Support::Json::extract_members |
( |
string::iterator & |
begin, |
|
|
string::iterator & |
end, |
|
|
Object & |
members |
|
) |
| |
Extract JSON values. Build JSON Object from values extracted from string containing JSON.
- Parameters
-
json | String containing JSON values. |
- Returns
- ::Object containing heirarchical vector of ::Member
102 members.emplace(tmember);
109 return static_cast<int32_t
>(members.size());
int32_t extract_member(string::iterator &bit, string::iterator &eit, Member &value)
Definition: jsonclass.cpp:141
int iretn
Definition: rw_test.cpp:37
string::iterator begin
Definition: jsonclass.h:87
pair< string, Value > Member
Definition: jsonclass.h:46
string::iterator end
Definition: jsonclass.h:88
int32_t Cosmos::Support::Json::extract_values |
( |
string::iterator & |
begin, |
|
|
string::iterator & |
end, |
|
|
Array & |
values |
|
) |
| |
125 values.push_back(tvalue);
132 return static_cast<int32_t
>(values.size());
int iretn
Definition: rw_test.cpp:37
string::iterator begin
Definition: jsonclass.h:87
int32_t extract_value(string::iterator &bit, string::iterator &eit, Value &value)
Definition: jsonclass.cpp:158
string::iterator end
Definition: jsonclass.h:88
int32_t Cosmos::Support::Json::extract_string |
( |
string::iterator & |
begin, |
|
|
string::iterator & |
end, |
|
|
string & |
ostring |
|
) |
| |
Extract next JSON string. Extract the next JSON String from the c++ string represented by the supplied iterator. Leave the iterator pointing to the beginning of the next value.
- Parameters
-
it | Reference to string iterator. |
- Returns
- The discovered string, or an empty string.
571 if (*(
begin) ==
'\\')
580 ostring.push_back(*(
begin+1));
583 ostring.push_back(
'\b');
586 ostring.push_back(
'\f');
589 ostring.push_back(
'\n');
592 ostring.push_back(
'\r');
595 ostring.push_back(
'\t');
612 ostring.push_back(*(
begin));
int iretn
Definition: rw_test.cpp:37
int32_t skip_character(string::iterator &bit, string::iterator &eit, const char character)
Definition: jsonclass.cpp:449
string::iterator begin
Definition: jsonclass.h:87
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
#define JSON_ERROR_SCAN
Definition: cosmos-errno.h:96
string::iterator end
Definition: jsonclass.h:88
int32_t skip_white(string::iterator &bit, string::iterator &eit)
Definition: jsonclass.cpp:433
int32_t Cosmos::Support::Json::extract_name |
( |
string::iterator & |
bit, |
|
|
string::iterator & |
eit, |
|
|
string & |
name |
|
) |
| |
int iretn
Definition: rw_test.cpp:37
int32_t skip_character(string::iterator &bit, string::iterator &eit, const char character)
Definition: jsonclass.cpp:449
string::iterator begin
Definition: jsonclass.h:87
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
string name
Definition: cubesat2obj.cpp:6
int32_t extract_string(string::iterator &bit, string::iterator &eit, string &ostring)
Definition: jsonclass.cpp:543
string::iterator end
Definition: jsonclass.h:88
int32_t skip_white(string::iterator &bit, string::iterator &eit)
Definition: jsonclass.cpp:433
int32_t Cosmos::Support::Json::extract_value |
( |
string::iterator & |
begin, |
|
|
string::iterator & |
end, |
|
|
Value & |
value |
|
) |
| |
Extract next JSON value. Extract the next JSON value from the c++ string represented by the supplied iterator. Leave the iterator pointing to the beginning of the next value.
- Parameters
-
it | Reference to string iterator. |
- Returns
- A pointer the the discovered value, or a nullptr.
230 value.svalue.clear();
233 for (i2=1; i2<ilen; i2++)
235 if (*(
begin+i2) ==
'"')
237 if (*(
begin+i2) ==
'\\')
239 switch (*(
begin+i2+1))
244 value.svalue.push_back(*(
begin+i2+1));
247 value.svalue.push_back(
'\b');
250 value.svalue.push_back(
'\f');
253 value.svalue.push_back(
'\n');
256 value.svalue.push_back(
'\r');
259 value.svalue.push_back(
'\t');
268 value.svalue.push_back(*(
begin+i2));
394 value.svalue.clear();
401 value.svalue.push_back(*
begin);
408 sscanf(value.svalue.c_str(),
"%lf", &value.nvalue);
430 return static_cast<int32_t
>(value.type);
int32_t extract_members(string::iterator &begin, string::iterator &end, Object &members)
Definition: jsonclass.cpp:89
int iretn
Definition: rw_test.cpp:37
int32_t extract_values(string::iterator &begin, string::iterator &end, Array &values)
Definition: jsonclass.cpp:112
int32_t skip_character(string::iterator &bit, string::iterator &eit, const char character)
Definition: jsonclass.cpp:449
string::iterator begin
Definition: jsonclass.h:87
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
#define JSON_ERROR_SCAN
Definition: cosmos-errno.h:96
string::iterator end
Definition: jsonclass.h:88
int32_t skip_white(string::iterator &bit, string::iterator &eit)
Definition: jsonclass.cpp:433
int32_t Cosmos::Support::Json::extract_member |
( |
string::iterator & |
begin, |
|
|
string::iterator & |
end, |
|
|
Member & |
member |
|
) |
| |
Extract JSON member. Extract next member of JSON Obect from provided string.
- Parameters
-
begin | Beginning string iterator. |
end | End string iterator. |
value | ::Member containing value. |
- Returns
- Zero or negative error.
int iretn
Definition: rw_test.cpp:37
string::iterator begin
Definition: jsonclass.h:87
int32_t extract_name(string::iterator &bit, string::iterator &eit, string &name)
Definition: jsonclass.cpp:500
int32_t extract_value(string::iterator &bit, string::iterator &eit, Value &value)
Definition: jsonclass.cpp:158
string::iterator end
Definition: jsonclass.h:88
int32_t Cosmos::Support::Json::skip_character |
( |
string::iterator & |
bit, |
|
|
string::iterator & |
eit, |
|
|
const char |
character |
|
) |
| |
464 if (*
begin != character)
int iretn
Definition: rw_test.cpp:37
string::iterator begin
Definition: jsonclass.h:87
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
string::iterator end
Definition: jsonclass.h:88
int32_t skip_white(string::iterator &bit, string::iterator &eit)
Definition: jsonclass.cpp:433
int32_t Cosmos::Support::Json::skip_to_character |
( |
string::iterator & |
bit, |
|
|
string::iterator & |
eit, |
|
|
string |
characters |
|
) |
| |
483 for (
char character : characters)
485 if (*
begin == character)
string::iterator begin
Definition: jsonclass.h:87
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
string::iterator end
Definition: jsonclass.h:88
int32_t Cosmos::Support::Json::skip_white |
( |
string::iterator & |
bit, |
|
|
string::iterator & |
eit |
|
) |
| |
string::iterator begin
Definition: jsonclass.h:87
#define JSON_ERROR_EOS
Definition: cosmos-errno.h:95
string::iterator end
Definition: jsonclass.h:88
string Cosmos::Support::Json::Content |
Type Cosmos::Support::Json::JType |
Object Cosmos::Support::Json::ObjectContents |
Array Cosmos::Support::Json::ArrayContents |
string::iterator Cosmos::Support::Json::begin |
|
private |
string::iterator Cosmos::Support::Json::end |
|
private |
The documentation for this class was generated from the following files: