Forum Academy Marketplace Showcase Pricing Features

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

I’ve found another bug, in the readJSON operator, in the function getValue(key) function declaration.

The following “if / else” (used when you have a key containing some . separators) is not working to get “non object” results.

		if (key.split('.').length > 1){
			let foundObj = obj;
			for (let thisKey of key.split('.')){
				if (typeof foundObj[thisKey] == 'object'){
					foundObj = foundObj[thisKey]
				}
				else {
					return foundObj;
				}
			}
			return foundObj;
		}

Indeed, if the last item targeted by the key is not an object (so if typeof foundObj[thisKey] == 'object' is false), it’s the foundObj which is returned (which is the object from the previous iteration) instead of foundObj[thisKey].

So, in fact, I think you should do a return foundObj[thisKey]; here. (I think the return is here to interrupt the loop if you reached a non-object point ?).

1 Like

Are you experiencing an unexpected behavior at runtime?

Yes, for example :

Input JSON :

{
  "firstLevel": {
    "secondLevel": "value"
  }
}

Key : firstLevel.secondLevel

Expected result :

"value"

Current result :

{
  "secondLevel": "value"
}
1 Like

Great plugin!

I’m facing a similar issue because of the dot thing (.) In the key itself

I have an key called ‘topics.topic-level1’ that the plugin doesn’t recognize as a key or return any values … this an external service and I don’t have control of the key naming conviction. Tried to add " or ’ but didn’t work as well.

Any solution for that?

Hi all!
I’ve published a new plugin after fighting a lot with JSON Machine and other json related plugins. I think I took all the best things in one plugin, which easily stores and reads json data as well as support JsonPath format for reading.

@jon2 Feel free to update JSON Machine plugin with my code if you find something useful.
Have fun!

1 Like

Great to see the community working to improve JSON support!

I may do this if I find the time. :slight_smile: JSON machine was initially built out of a personal need but clearly has many, many more use cases and a lot of room for improvement and I’m glad to see an effort made to do just that!

I’ve since stopped active development of JSON machine and am only making bug-fix updates and even that isn’t where I’d like it to be.

Congrats on the launch!

1 Like

Does anyone have instructions on how to just display a list in RG from a field thats holding the json, i’m not having any luck, not sure why it would be so difficult to do a simple task.

1 Like

(better late than never) have you looked at the example app? this shows a repeating group that is sourced from a JSON. If you target a readJSON element to an array value it will produce a list of text, number, etc value that can be read by an RG

JSON machine will only work with JSON data that is structured as an Array (list) to produce a list in bubble. It won’t know what to do with a bunch of unorganized key/value pairs.

Hi there,

New update:
Improved ability to get nested values from JSON. This was only partially functional before.
Example:

With the JSON
{ “hair” :
  {
    “color” : “brown” }
  }
}

you can now access the value for color by using hair.color as your key to read from.

the example app now shows the source JSON in ‘pretty print’ to make it easier to follow along

Maybe it’s just me but even when following your template, I can’t modify any json values.

Is this a bug or am I doing it wrong?