Page 1 of 1

[HowTo] Understanding, viewing and editing JSON files

Posted: 30 Jun 2014 03:01
by kambis
as part of my studies on Z-Way programming and debugging, I was faced to read and understand JSON files within the home automation Module and userModule folders.

Google searches resulted into several tools especially online ones for handling JSON files. But one local editing tool was in my case the winner and helped me to easily work with JSON files. This info might be interesting for others in this forum:

A small easy windows EXE file called JSONedit seems to be a good helper. here the link to the site: At the end of page you can download the latest version 0.9.8 (as per 30.06.2014) and have a look at it. Also the data on the site was very helpful for me.

Now if Z-Way developers would provide some data about implemented JSON features in the Z-Way-Server, then one could modify and generate much more easier JSON files for home automation modules.

Re: Understanding, viewing and editing JSON files

Posted: 30 Jun 2014 05:21
by pofs
Which "JSON features" are you talking about?

State files under /automation/storage can be loaded with:

Code: Select all

var obj = loadObject("name");
After that obj will be just a JS object containing values from JSON file.
You may add, remove or modify properties of obj and its child objects.

Code: Select all

obj.a = 1;
obj.b = {};
obj.b.c = 2;
delete obj.a;
Object can be saved with:

Code: Select all

As folder name suggests, it is a storage for module data, it shouldn't be edited by user. File names are derived from object names and can't be easily guessed.

You can also load objects from arbitrary JSON file with:

Code: Select all

var obj = loadJSON("path");
The only difference from loadObject() is that you can specify file path instead of object name.
loadJSON() is more suitable for config files readable and editable by human.

Also there are built-in JSON.stringify() and JSON.parse() functions.

Understanding module.json files

Posted: 30 Jun 2014 09:25
by kambis
Thank you pofs.
The features I'm asking are about keywords possible for module.json files mentioned in the latest Z-Way Developers Documentation, version 1.7 ( ) on page 49. The few lines there explaining about autoload, singleton, defaults, actions and metrics are not reflecting all the keywords I'm finding in several module.json files in the automation/modules/* subfolders.

You find there key words like: options, schema, required, lable, helper, user view, title, description, field, type and many many other keywords beside the metadata within the files.

My question is if there is any kind reference data how to compose those files or
understand how they are built.

Re: Understanding, viewing and editing JSON files

Posted: 08 Jul 2014 11:00
by PoltoS
Indeed, options and schema are not really documented. Here we use third part AlpacaJS project. The only extension we have made is namespaces:... stuff to load data from dictionaries. These are quite obvious. Other things are documented in AlpacaJS project. I would suggest to look on examples in modules and copy them.

Reference documentation for module.json files

Posted: 08 Jul 2014 16:54
by kambis
based on your information I found the link: ... field.html

which explains in detail many of my questions and I see in addition modifications beyond namespaces:... stuff.
For example you use the keyword defaults {...} instead the keyword data {...} or you define in your document Z-Way Developers Documentation, version 1.7 ( ) on page 49 additional keywords like actions and metrics.

I was also not able to play around with the "VIEW_WEB_EDIT", "VIEW_WEB_EDIT_LIST", "VIEW_WEB_EDIT_TABLE" options in the layout.

Do you have any additional data, which you can provide about namespaces,
layout options or other modifications :?:

Re: Understanding, viewing and editing JSON files

Posted: 08 Jul 2014 22:06
by PoltoS
We never used layouts. not even tested them.

Indeed, defaults is additional stuff from us - we use it to initialize data if empty. But note that data is read from config.json file in storage/ and is filled automatically.

As for namespaces, there is a field saying that data will come from a namespace. Then after : goes the name of the namespace and then after another : the key to be used (in optionLabels we use deviceName, in schema - deviceId)

Example code for module.json file

Posted: 13 Jul 2014 20:44
by kambis
After studying the information given on ... field.html
I could manage to create my own module.json file for my first automation userModule.

More data is available in this post: