how to construct the binary file included in the json file using c++ in backend

I am new to web development, I want to convert my own data to binary file as the file in the folder: “cow.vtp\data \5ab532bd952db1f3d2b7a5e2c1ffca47” with cpp application runs on the server, so I can use vtkHttpDataSetReader to process my data like the example shows. But I have no idea how to archieve it. codes like ofstream binaryio("temp.dat", ios::binary) then write the binary file to the disk I have tryed do not work, Many thanks to those who answered my question.


When writing raw binary data, make sure you properly handle the server’s OS’s endianess. I mean, if you assumed the OS is little endian (e.g.: Windows) the file will be incorrect if the host OS is big endian (some POSIX OSes).

You can test for endianess in C++ with one of the codes proposed here: algorithm - Detecting endianness programmatically in a C++ program - Stack Overflow. Read the comments carefully, as you’re dealing with low level programming.

take care,