How to Convert MHTML to JSON on C++: Step-by-Step Code Example
// Converting to MHTML using Aspose.Words
using namespace aspose::words::cloud;
auto requestSaveOptionsData = std::make_shared< aspose::words::cloud::models::HtmlSaveOptionsData >();
requestSaveOptionsData->setFileName(std::make_shared< std::wstring >(baseTestOutPath + L"/TestConvertFile_CPP.html"));
std::shared_ptr<requests::SaveAsRequest> request(new requests::SaveAsRequest(
std::make_shared< std::wstring >(remoteFileName),
requestSaveOptionsData,
std::make_shared< std::wstring >(remoteFolder),
nullptr,nullptr,nullptr,nullptr,nullptr ));
auto actual = getApi()->saveAs(request);
%!(EXTRA string=HTML, string=MHTML, string=HTML)
// Converting to HTML using Aspose.Cells
std::shared_ptr<requests::ConvertRequest> request(new requests::ConvertRequest(
std::make_shared< std::wstring >("JSON") ,
requestFile,nullptr,nullptr,nullptr));
auto actual = getApi()->convert(request);
if(actual->good()){
std::ofstream out("TestConvertFile_CPP.HTML", std::istream::binary);
actual->seekg(0,std::ios_base::beg);
while(!actual->eof()){
char* buffer = new char[256];
actual->read(buffer,256);
out.write(buffer,256);
}
}
%!(EXTRA string=JSON)
Transform MHTML into JSON with the C++ Cloud SDK
- Initialize WordsApi and CellsApi with Client Id, Client Secret, Base URL & API version
- Set ConvertDocumentRequest with parameters local file name and format as HTML
- Call WordsApi convertDocument to convert MHTML document to HTML
- Initialize SaveOption from CellsAPI with parameters SaveFormat as JSON
- Call cellsSaveAsPostDocumentSaveAs method to convert MHTML file to JSON
Start leveraging Aspose.Total REST APIs for MHTML to JSON
- Create an account at Dashboard to get free API quota & authorization details
- Get Aspose.Words and Aspose.Cells Cloud SDKs for C++ source code from Aspose.Words GitHub and Aspose.Cells GitHub repos to compile/use the SDK yourself or head to the Releases for alternative download options.
- Also have a look at Swagger-based API Reference for Aspose.Words and Aspose.Cells to know more about the REST API.
How to Convert Word MHTML to other formats online
Transform MHTML files into HTML format using Aspose.Words API, and seamlessly integrate them with any Aspose.Total APIs, such as Aspose.Cells, Aspose.PDF, Aspose.Email, Aspose.Slides, Aspose.Diagram, Aspose.Tasks, Aspose.3D, Aspose.HTML. This enables conversion of your files into hundreds of different formats.
For a complete list of supported formats, visit the Aspose.Total Cloud page.
How to Convert MS Word Documents, MHTML to Image Formats
Aspose.Words Cloud SDK offers fast and straightforward methods to convert MS Word files into various image formats, just like we did above for JSON. Whether through direct REST API calls or SDKs, you can easily convert Word documents to multiple image formats, including JPEG, PNG, BMP, GIF, and TIFF, using Aspose.Words Cloud APIs.
- Create ConvertDocumentRequest object to convert MHTML document
- Call ConvertDocument method of WordsApi class instance for conversion from MHTML
Simple Steps to Convert MHTML to PDF Online
For MHTML to PDF please follow these steps:
- Visit the MHTML to PDF webpage.
- Upload your MHTML file from your device.
- Click on the “Convert” button.
- Wait for the conversion to finish.
- Once the conversion is complete, download the PDF file to your device.
How to Convert Webpage to JSON format
To convert a webpage to the JSON format, follow these steps:
- Visit the “Webpage to JSON” website.
- Enter the URL of the webpage you wish to convert into the designated input box.
- Click the “Convert” button to initiate the conversion process.
- Wait for the conversion to complete.
- Download the JSON file to your device once the conversion is finished.
By following these steps, you can easily convert and download webpages in the desired JSON format for offline access and further use.
FAQ
-
What is MHTML Format?
Files with MHTML extension represent a web page archive format that can be created by a number of different applications. The format is known as archive format because it saves the web HTML code and associated resources in a single file. These resources include anything linked to the webpage such as images, applets, animations, audio files and so on. MHTML files can be opened in a variety of applications such as Internet Explorer and Microsoft Word. Microsoft Windows uses MHTML file format for recording scenarios of problems observed during the usage of any application on Windows that raises issues. The MHTML file format encodes the page contents similar to specifications defined in message/rfc822 which is plain text email related specifications. The actual specifications of the format are as detailed by RFC 2557.
-
What is JSON Format?
JSON (JavaScript Object Notation) is an open standard file format for sharing data that uses human-readable text to store and transmit data. JSON files are stored with the .json extension. JSON requires less formatting and is a good alternative for XML. JSON is derived from JavaScript but is a language-independent data format. The generation and parsing of JSON is supported by many modern programming languages. application/json is the media type used for JSON.
-
Starting with Aspose.Total REST APIs Using C++ SDK: A Beginner's Guide
Quickstart not only guides through the initialization of Aspose.Total Cloud API, it also helps in installing the required libraries.
-
Where can I find the Aspose.Total Cloud API release notes for C++?
Complete release notes can be reviewed at Aspose.Total Cloud Documentation.
-
Is it safe to convert MHTML to JSON in the Cloud?
Of course! Aspose Cloud uses Amazon EC2 cloud servers that guarantee the security and resilience of the service. Please read more about Aspose's Security Practices.
-
What file formats are supported by Aspose.Total Cloud API?
Aspose.Total Cloud can convert file formats from any product family to any other product family to PDF, DOCX, XPS, image(TIFF, JPEG, PNG BMP), MD and more. Checkout the complete list of supported file formats.
-
I can not find the SDK for my favorite language. What should I do?
Aspose.Total Cloud is also available as a Docker Container. Try using it with cURL in case your required SDK is not available yet.