Add sax converter from json to xml
[anna.git] / source / json / functions.cpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #include <anna/json/functions.hpp>
10 #include <anna/json/SaxConsumer.hpp>
11
12
13 std::string anna::json::functions::json2xml(const std::string &json, bool & success) {
14
15   // create a SAX event consumer object
16   anna::json::SaxConsumer consumer;
17
18   // parse and serialize JSON
19   success = nlohmann::json::sax_parse(json, &consumer);
20
21   // output the result of sax_parse
22   return consumer.getResult().str();
23 }