Cheedoong / xml2json

A header-only C++ library converts XML to JSON
MIT License
300 stars 102 forks source link

Way to access value from key of xml-converted json? #21

Closed gurbaaz27 closed 2 years ago

gurbaaz27 commented 2 years ago

Hi! I have an xml file with the following content `<?xml version="1.0"?>

Sample Book Name New Author 102.50

`

and using the xml2json.cpp, I get the following json string {"Book":{"name":"Sample Book Name","author":"New Author","price":102.5}}

Instead I want to obtain just {"name":"Sample Book Name","author":"New Author","price":102.5}

Is there any way I could do this? I tried going and looking through xml2.json.hpp, rapidjson/document.h and rapidjson/writer.h, but could not do. Any help would be appreciated!

Regards

gurbaaz27 commented 2 years ago

Solved: rapidjson::Value& t = js_doc["Book"]; t.Accept(buffer);