New FREE Plugin - JSON Machine. Work with JSON direct on the page

Oh! Ok so in order to see the output of the json machine element i need to reference its value. It doesnt write is value back to the source of the original json, it just stores the result internally. Just like the reader side it translates but its results must be pulled via a workflow step or a reference from another element.

Did I state the concept of how the engine works correctly? @jon2

As I have not received any help in my doubts, I will even do an update of what I have learned during my lonely fight! Maybe this helps some noob like me… :worried:
Well, so far, after 2 uninterrupted days of useless testing I was able to read a value in a Json text. :thinking:

1º - I put the Json text in a field within a Bubble DB named User (as in the example that was made available).
2º- I put 1 Group with Type of COntent = User , and Data Source = Current User.
3º- Within this Group, I put a readJSON element with Key = name of the cell we want to read , and the field of json text = Parent ́sGroup User ́s json. (json is the name of the database field that contains my JSon texts).
4º- To write this read value I put within this Group another element, a Text with a dynamic value in the text field with the name of the readJSON previously placed followed by text ́s value.

Looks like a simple operation , but it´s not!!! :roll_eyes:

Now i will try to find a value of a cell inside another cell… Maybe in 2 days again I can understand wath the f… is going on! :face_with_monocle:

I hope this could help someone. :wink:

1 Like

You described this correctly. The plug-in does not talk directly to the database. it stores the output data in an internal state, you then use the bubble workflow logic to do something with that output (display it to the user, save it to the db).

Have you tried troubleshooting this inside the bubble debugger to see if the json text is actually making it to json machine? You can also put a text element that shows the contents of “current users json” just to make sure you are actually getting the value you think you are.

1 Like

Thanks for the help Jon,
I will try this…

UAu, totally unexpected! Insane behavior detected. My DB User has a data called json with the typical JSON text of the heroe ́s squad provided as an example ! Okay, perfect… but it seems that by changing the text within the DB User field called json… it continues with the hero’s squad data! When creating a field in this same DB User called jsonc, to test another JSON, he does not accept reading this new field! I’m finding it very strange… would it be a bug? Is there a limitation of what we can use? Is my JSON text incorrect? (I think it’s the last most likely option) … the triall and error mode keeps going… :exploding_head:

User testing in preview can be tricky. I’d double check and make sure you are testing the user that you think you are. You can display the current users email. This sounds like a permissions issue.

Good luck

1 Like

Jon, you rulles dude.
Indeed it was a current user issue…
whem i register and log in a user it updated! Strange preview´s peculiarity…:face_with_monocle:
Are you from Bubble team, or do you have only Json MAchine plugin? If you´re not from bubble, they should consider contracts you!
Thank you very much for your help. :+1: :pray:

Been there

Been there with this exact issue myself. If you spend enough time beating your head against the wall, eventually you may also become an ‘expert’ (I use that term for myself very loosely)

1 Like

Now I have new issues… Json Machine is not easy to use at the same time it is…
1- I canot acess data inside [ ] . I tried all options … i could read the inside [] values in a Text, but could not acess it by readJson. Anyone can help me with this?
Another question is:
2- can I use a json data out of the User DB? I tryed to make another one, but it seens i can readJson only in User DB, and, in a field called “json”, just like in example sample… I think this should be something I missed because there´s not any logic in mantain such limits!
Any help should be highly apreciated! Thanks in advance.

Strage things, as always with me!
I can get “members” fields, but I cannot acess the inside members list of jsons! Tryed thousands of configs. :thinking:
Anyone knows how to get only one field inside another? I did it like the example and doesn´t works… Aff . … :unamused:

As soon no awsers has been given to me, I returned after smashing my head in the screen until it works!
To take values within cells that are inside cells you need to go deeper and deeper into the hierarchy, obviously. But doing this isn’t as easy as it seems… so I’m going to play my workflow.

At each step in the hierarchy we must create a Group, or a Repeating Group to select the search space. So within this group we insert a ReadJson.Having taken the first level, we took another group or repeating group inside the first one.

Going into detail my assembly was like this:
1st group with User Type=User, Data Source= current User.
2nd within this Group we created a Repeating Group that will receive the ReadJson’s “Json variable from the beginning of the hierarchy” +get listOfJsonstexts" and a text with “current cell text” to get the value taken back.
3nd As I select the indexes that should be searched for by a Dropdown, I added within the latter a Repeating Group, type of content=text, and data source=Multidropdown Value’s.
4nd Still within this Repeating Group I put a readJson with key=current cell and json text=readJson of this same Repeating group + get list of Json texts.
5nd A Text will read this readJson value to draw it on the screen. A Text will read this readJson value to draw it on the screen.
6nd At each step in the hierarchy we add a Repeating group within the other with a readJson for each and a Text returning the d oReadJson values of the cell. At each step in the hierarchy we add a Repeating group within the other with a readJson for each and a Text returning the ReadJson values of the cell At each step in the hierarchy we add a Repeating group within the other with a readJson for each and a Text returning the d oReadJson values of the current cell

I hope this could help the comunitty, if yes, leave a Heart!

1 Like

Hi @jon2 ,

Thanks for the awesome plugin!

I’m trying to use the plugin to read something like this:
[{“Sales":"ezhangtest@gmail.com”,“Monthly Sale”:100000,“Month”:6},{“Sales":"ezhang@test.com”,“Monthly Sale”:200000,“Month”:4}]
In your example app, there is already a key “member” for the nested JSON text for the readjson element. Can you please provide some insights of how to read the JSON text above without a key?

Thanks,
Evan

JSON Machine uses text which defines an object in Javascript. What you’ve got here is text which defines an array and JSON machine cannot work with that natively. You could try merging your array’s text with the necessary text to convert the array into an object.

something like:

{ "examplearraykey" : + ** your array text ** + }

which should produce this as the output:
{ "examplearraykey" : [{“Sales":"ezhangtest@gmail.com”,“Monthly Sale”:100000,“Month”:6},{“Sales":"ezhang@test.com”,“Monthly Sale”:200000,“Month”:4}] }

This has now been formatted as the proper JSON object, which can be worked on with JSON machine, just target ‘examplearraykey’.

1 Like

Hi @jon2

Thank you so much for your suggestion! That makes sense!

Evan

Hey @jon2 !

Thanks for the plugin, it is really good ! Except that I’m encountering a bug in the Update action, on the JSON_arr field which is expected as json_arr in the code :slight_smile:
Could you fix it ? :slight_smile:

And there is also a bug in the parseArrayOfJSONs function, where you are using for (let jsonItem in arr) instead of for (let jsonItem of arr) (so you’re iterating on indexes instead of array’s items themselves :slight_smile: )

Hi Florian,

Nice catch. I’m thinking I don’t code enough in ES5 to use that somewhat-confusing nomenclature reliably :slight_smile: I’m surprised this hasn’t been mentioned before!

I’ll look at it.

I’ve pushed a fix. Take a look and let me know if you have any problems

It seems ok, thanks !

I’ve published a complementary plugin, allowing to use JSONata on a JSON ! Feel free to enjoy it :stuck_out_tongue:

1 Like