This is how i did it in the arctech_switch code:
```
	if(all == 1) {
		json_append_member(arctech_switch->message, "all", json_mknumber(all));
	} else {
		json_append_member(arctech_switch->message, "unit", json_mknumber(unit));
	}
```