Why to Convert
Converting documents from one format to another is a common requirement in many applications. For example, converting a DOCX file to JSON format can be useful for applications that need to store and manipulate data in a structured format. JSON is a popular data interchange format that is used to store and exchange data between different applications.
How Aspose.Total Helps for DOCX to JSON Conversion
Aspose.Total for C++ is a comprehensive suite of components that enables developers to create, manipulate and convert various document formats within their C++ applications. It includes Aspose.Words for C++, which can be used to export DOCX files to HTML. Aspose.Cells for C++ can then be used to convert the HTML to JSON format. This makes it easy to convert DOCX to JSON within C++ applications.
Convert DOCX to JSON Format via C++
Get Started with C++ File Automation APIs
Install via Package Manager Console of Visual Studio with Install-Package Aspose.Total.Cpp
.
Alternatively, get the offline MSI installer or DLLs in a ZIP file from downloads .
// supports DOC, DOT, DOCX, DOCM, DOTX, DOTM, RTF, WordML, MOBI, ODT, and OTT file formats | |
// load DOCX as input file format with an instance of Document class | |
auto doc = MakeObject<Document>(u"Input.docx"); | |
// save document in HTML format | |
doc->Save(u"Output.html"); | |
// Load the HTML. | |
intrusive_ptr<Aspose::Cells::IWorkbook> wkb = Factory::CreateIWorkbook(u"Output.html"); | |
// Save in JSON format. | |
wkb->Save(u"Output.json", SaveFormat_Json); |
Convert Protected DOCX to JSON Format via C++
Using the API, you can also open the password-protected document. If your input DOCX document is password protected, you cannot convert it to JSON format without using the password. To do this, use a special constructor overload, which accepts a LoadOptions object. This object contains the Password property, which specifies the password string.
// supports DOC, DOT, DOCX, DOCM, DOTX, DOTM, RTF, WordML, MOBI, ODT, and OTT file formats | |
// Loads encrypted document. | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(u"LoadEncrypted.docx", System::MakeObject<LoadOptions>(u"aspose")); | |
// save document in HTML format | |
doc->Save(u"Output.html"); | |
// Load the HTML. | |
intrusive_ptr<Aspose::Cells::IWorkbook> wkb = Factory::CreateIWorkbook(u"Output.html"); | |
// Save in JSON format. | |
wkb->Save(u"Output.json", SaveFormat_Json); |