mu: support json output directly

Allow for dumping json directly from the Sexp structures, so we don't
need any external libs (i.e. json-glib) anymore.
This commit is contained in:
Dirk-Jan C. Binnema
2020-10-26 18:39:56 +02:00
parent f2e87ea2d4
commit d2aa1f91b0
10 changed files with 93 additions and 66 deletions

View File

@ -104,11 +104,19 @@ struct Sexp {
}
/**
* Convert a Sexp::Node to its string representation
* Convert a Sexp::Node to its S-expression string representation
*
* @return the string representation
*/
std::string to_string() const;
std::string to_sexp_string() const;
/**
* Convert a Sexp::Node to its JSON string representation
*
* @return the string representation
*/
std::string to_json_string() const;
/**
* Return the type of this Node.
@ -341,7 +349,7 @@ operator<<(std::ostream& os, Sexp::Type id)
static inline std::ostream&
operator<<(std::ostream& os, const Sexp& sexp)
{
os << sexp.to_string();
os << sexp.to_sexp_string();
return os;
}