# Module JSON data implementation

**URL:** <https://forum.4ms.info/t/module-json-data-implementation/146>\
**Category:** Plugin Development\
**Created:** [September 3, 2024, 2:02pm UTC](https://forum.4ms.info/t/module-json-data-implementation/146 "2024-09-03T14:02:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![janne808](https://forum.4ms.info/user_avatar/forum.4ms.info/janne808/32/75_2.png) [@janne808](https://forum.4ms.info/u/janne808)\
**Post date:** [September 3, 2024, 2:02pm UTC](https://forum.4ms.info/t/module-json-data-implementation/146/1 "2024-09-03T14:02:04Z")

</div>

Hello,

Finally got my Meta Module yesterday and messed around with it a bit.

I noticed there is something weird going on with module JSON data in patches and I’m guessing dataFromJson() method is not currently implemented?

Really cool module and I bet it was a ton of work so congrats on getting it out the door!

---

<div class="post-metadata">

**Author:** ![janne808](https://forum.4ms.info/user_avatar/forum.4ms.info/janne808/32/75_2.png) [@janne808](https://forum.4ms.info/u/janne808)\
**Post date:** [September 6, 2024, 3:23am UTC](https://forum.4ms.info/t/module-json-data-implementation/146/2 "2024-09-06T03:23:55Z")

</div>

Looked into this more: dataFromJson() method is implemented in the Meta Module VCV module wrapper and it definitely works.

The problem was that in my kocmoc VCV module code it was assumed that dataFromJson() should only read the JSON data into the struct variable and other methods would set and act on the new values, which is what happens in VCV Rack but it doesn’t on Meta Module (because menu items aren’t supported? I don’t know…)

Acting on new values explicitly inside the plugin dataFromJson() method corrected this issue.

---

<div class="post-metadata">

**Author:** ![danngreen](https://forum.4ms.info/user_avatar/forum.4ms.info/danngreen/32/14_2.png) [@danngreen](https://forum.4ms.info/u/danngreen)\
**Post date:** [September 6, 2024, 6:58pm UTC](https://forum.4ms.info/t/module-json-data-implementation/146/3 "2024-09-06T18:58:39Z")

</div>

Hi Janne! First of all, thanks for the kocmoc modules!

So, you’re right, `dataFromJson()` is called when a module loads, but menus are not supported, so a module needs another way to modify those if it’s to be done from with MetaModule.

MetaModule does support “AltParams” which are hidden parameters that don’t show up on the panel, but are at the bottom of the list of elements when you click on a module. For example, see Marbles (aka Random-Maker), at the bottom of the list of knobs and jacks is “Scale”, where you can choose the scale to quantize to.  
This was added manually, BTW, here:

> <https://github.com/4ms/AudibleInstruments/blob/cce4365407deb441cd8294e20750e1754be1ebf2/src/Marbles.cpp#L373-L378>

(and the other two places where `X_SCALE_PARAM` appears in that file), and here:

> <https://github.com/4ms/metamodule/blob/fd1e4bcbb753c0bd9ba7b8c0a35abc0952f8221f/firmware/vcv_ports/glue/AudibleInstruments/info/Marbles_info.hh#L61-L62>

Marbles is a little different because it’s built-into the firmware, so until I make an API for creating an AltParam, you can’t do this with a plugin. It would be something like the calls to `addParam(createParam<WidgetType>(....))` but would be `addParam(createAltParam<AltParamType>(...))`

Ideally the MetaModule could scan and convert the VCV Menu callbacks and create AltParams from these, but I’m not sure it’s possible without creating a ModuleWidget instance for every module when the patch loads.

---

<div class="post-metadata">

**Author:** ![janne808](https://forum.4ms.info/user_avatar/forum.4ms.info/janne808/32/75_2.png) [@janne808](https://forum.4ms.info/u/janne808)\
**Post date:** [September 8, 2024, 8:13am UTC](https://forum.4ms.info/t/module-json-data-implementation/146/4 "2024-09-08T08:13:59Z")

</div>

> [@danngreen](#):
>
> Hi Janne! First of all, thanks for the kocmoc modules!

My pleasure.

> [@danngreen](#):
>
> Marbles is a little different because it’s built-into the firmware, so until I make an API for creating an AltParam, you can’t do this with a plugin. It would be something like the calls to `addParam(createParam<WidgetType>(....))` but would be `addParam(createAltParam<AltParamType>(...))`
> 
> Ideally the MetaModule could scan and convert the VCV Menu callbacks and create AltParams from these, but I’m not sure it’s possible without creating a ModuleWidget instance for every module when the patch loads.

Okay, for now the plugin loads the filter oversampling parameters from the patch JSON data so importing from VCV Rack works correctly.

I can add AltParams when they’re available for the plugin API.

> <https://github.com/janne808/kocmoc-rack-modules/commit/92690d5784b2b3199cdc47c430ed328d3e9c9e95>

There’s the latest commit for version 2.0.4 with the fixes if you want to update the website or if someone wants to compile it for themselves.

Plugin binary here:

> **[Release kocmoc plugin version 2.0.4 for MetaModule ·...](https://github.com/janne808/kocmoc-rack-modules/releases/tag/2.0.4)**
>
> MetaModule plugin release with fixes for proper patch JSON deserialization
