Read your Mendix model without using the Model SDK

18
Are you looking for alternative solutions to read the Mendix model without using the Model SDK? For instance if you like to read models that are not stored on the Mendix team server, if you do not want to wait for creation of online working copies or if you don't like to use Javascript :P! Found out that Mendix uses MongoDB BSON (binary JSON) files to store the Mendix model. In your project folder, there is a deployment folder once you have deployed. Go to the model folder and you will find a model.mdp file.  Reading BSON files can be done in Java using org.bson.BasicBSONDecoder. You can convert the file to a normal JSON using command line tools as well: https://docs.mongodb.com/manual/reference/program/bsondump/. In Windows, you need to install the MongoDB tools, in Ubuntu you can type "sudo apt install mongodb-clients".  Then type "bsondump --type=json model.mdp > model.json" and your JSON file will be saved to model.json, which exposes your Mendix model.
asked
4 answers
3

You can actually open the MPR file, which is in SQLite format (can use https://sqlitebrowser.org/). All documents in the model (for instance the Microflows or Domain models) are stored in database Blobs (binary objects) in table Unit and column Contents. The blobs are actually again in the BSON format. So you can decode them using the first post in this forum thread. This information DOES contain the Modeler-specific metadata.

answered
2

One addition to this post, the model.mdp file contains all functional information that is used by the Mendix Runtime to read the model, but not the metadata that is used by the Modeler to picture all elements on the canvas (e.g. position of entities). Probably you need the MPR file to do that, but I don't know the file format (yet).

answered
2

Note that there's also MprTool.exe that's standard included with the Mendix Modeler installation. See C:\Program Files\Mendix\<version>\modeler\MprTool.exe. It allows you to navigate through a tree view of an mpr file.

answered
0

Hi Menno,

I don't think I have figured out the usecase yet ...I am also pretty new to the Model SDK, was recently playing with typescript in order to obtain the whole model indeed.

But when I have converted the file, and do read for example: {"$ID":"0ZJT5UMH2Uaz5eCD8jDfWQ==","$Type":"Forms$Layout"},{"$ID":"A9eeGhIzGkKBz4bDv+JPFg==","$Type":"Forms$Layout"}.

Can you may explain how to see the models like entities, pages, microflows and their activities?

 

answered