I have to receive data from server. Server's application is written in VS2008 (MFC). There is only one way to send this data from server -> as CArchive object. I can't change server source.
I want to receive this data in PHP (by tcp), and convert them to JSON. Is it any smart way to convert CArchive to JSON?
CArchivedoesn't have a predefined format that you can parse. It's just a binary file which is application dependent. You have to know what is in it to know how to read it. A library could make it easier to read some data types (CString,CArray, etc.) but I'm not sure you'll find anything like this.The following example shows how
CArchiveworks (storing part):So you would have to read binary data and somehow interpret it. This is easy in C++ because MFC frameworks knows exactly how to serialize types, including complex types like
CStringandCArray. But you'll have to do this on your own using PHP.For example you might read 4 bytes at specified offset and interpret it as
int. Next four bytes forfloat. And then you have to see how to loadCString, it stores the length first and then data, but you'll have to take a look at the exact format it uses.There is no ready-to-go/use
CArchive-> JSON converter. I'd suggest you to modify your server code to produce bothCArchiveand JSON data.