Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues #41 and #43 #44

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ const char * UINT_FORMAT = "%u";
/*! \brief Format used for long integer to string conversion */
const char * LONG_FORMAT = "%li";

/*! \brief Format used for long long integer to string conversion */
const char * LONG_LONG_FORMAT = "%lli";

/*! \brief Format used for unsigned long integer to string conversion */
const char * ULONG_FORMAT = "%lu";

/*! \brief Format used for unsigned long integer to string conversion */
const char * ULONG_LONG_FORMAT = "%llu";

/*! \brief Format used for character to string conversion */
const char * CHAR_FORMAT = "%c";

Expand Down Expand Up @@ -735,7 +741,6 @@ std::string json::parsing::encode_string(const char *input)
{
case '"':
case '\\':
case '/':
result += "\\";
result += *input;
break;
Expand Down Expand Up @@ -830,7 +835,9 @@ std::vector<std::string> json::parsing::parse_array(const char *input)
json::jobject::entry::operator int() const { return this->get_number<int>(INT_FORMAT); }
json::jobject::entry::operator unsigned int() const { return this->get_number<unsigned int>(UINT_FORMAT); }
json::jobject::entry::operator long() const { return this->get_number<long>(LONG_FORMAT); }
json::jobject::entry::operator long long() const { return this->get_number<long long>(LONG_LONG_FORMAT); }
json::jobject::entry::operator unsigned long() const { return this->get_number<unsigned long>(ULONG_FORMAT); }
json::jobject::entry::operator unsigned long long() const { return this->get_number<unsigned long long>(ULONG_LONG_FORMAT); }
json::jobject::entry::operator char() const { return this->get_number<char>(CHAR_FORMAT); }
json::jobject::entry::operator float() const { return this->get_number<float>(FLOAT_FORMAT); }
json::jobject::entry::operator double() const { return this->get_number<double>(DOUBLE_FORMAT); }
Expand Down
14 changes: 13 additions & 1 deletion json.h
Original file line number Diff line number Diff line change
Expand Up @@ -667,12 +667,18 @@ namespace json
/*! \brief Casts the value as an unsigned integer */
operator unsigned int() const;

/*! \brief Casts teh value as a long integer */
/*! \brief Casts the value as a long integer */
operator long() const;

/*! \brief Casts the value as a long long integer */
operator long long() const;

/*! \brief Casts the value as an unsigned long integer */
operator unsigned long() const;

/*! \brief Casts the value as an unsigned long long integer */
operator unsigned long long() const;

/*! \brief Casts teh value as a char */
operator char() const;

Expand Down Expand Up @@ -965,9 +971,15 @@ namespace json
/*! \brief Assigns a long integer */
void operator=(const long input) { this->set_number(input, "%li"); }

/*! \brief Assigns a long long integer */
void operator=(const long long input) { this->set_number(input, "%lli"); }

/*! \brief Assigns a long unsigned integer */
void operator=(const unsigned long input) { this->set_number(input, "%lu"); }

/*! \brief Assigns a unsigned long long integer */
void operator=(const unsigned long long input) { this->set_number(input, "%llu"); }

/*! \brief Assigns an character */
void operator=(const char input) { this->set_number(input, "%c"); }

Expand Down