• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Parsing JSON data (from ZOO)

chris.paschen

Chris Paschen
I'm trying to access data in the ZOO_items table (from the Yoothemes ZOO exetension).
I just need to get the data stored in the element that is in JSON format and have it be in 'human readable' format.

I'm not conversant with ways to parse JSON properly.
Is there a way to just have the JSON data parsed for display (and ideally export) using javascript, etc.?
Is there a 'JSON Element' somewhere that would make this easier?

Any ideas about how to best 'view' ZOO data from within Fabrik would be very helpful.
 
I wouldn't usually delve in to a Community posting this deeply, but I'm interested in getting Fabrik to play nice with ZOO. So ... I can't guarantee I'll provide much help, but ...

Decoding it is relatively simple. In PHP it's ...

$decoded_json = json_decode($json_stuff);

... and in JavaScript it's ...

var decoded_json = JSON.decode(json_stuff);

But ... all that does is convert the encoded JSON string in to the coresponding data structure. So, for example, ["1","2","3"] get turned in to an actual array, with three entries with values 1, 2 and 3.

What you actually do with that data, and render it for "human consumption" is entirely dependent on what the data is. So your question is pretty much impossible to answer, without some examples of the data.

For example, we use JSON to store (say) checkbox results. So if you've selected items with values 1 and 3, the checkbox field in our table would be ["1","3"]. Which makes sense to us, as we know to then look at your Fabrik element metadata, work out what checkbox options have those values, grab the labes for those values, yada yada. But to any app outside Fabrik, that's essentially meaningless.

So ... are you trying to render the ZOO table directly in Fabrik, i.e. you've built a Fabrik List on top of it? if so, can yu add extra fields to the ZOO table(s) without messing with ZOO's head? If so, the easiest way would probably be to add an extra 'calc' element to the form, which will add an extra field to the table. Then put some code in the calc that decodes the data from the JSON formatted field (element), and outputs it in whatever format you need.

But I'd need an example to actually give you some sample code.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top