Forum Academy Marketplace Showcase Pricing Features

Convert Single Json Object to a List

Hello bubblers.

I am working with crm api that allows me to call an option set field directly.

The response is a single json object called data, with a nested list of key value pairs.

It is those key value pairs I would like to use as a dynamic drop down. Unfortunately, bubble only recognizes the single object called “data”, and does not treat the list of key value pairs as a list of objects.

see image:

Any tips?

Bubble recognizes all value pair. The issue is that the API provide a dictionnary of key pair and not a list (array).
You could probably set the API to receive a text and convert it to a list using split by or extract with regex.

So fiddling with using find & replace I was able to turn the object into a list of objects. This was able to get bubble to recognize there were several items.

So from this:

{
"ResponseCode": 200,
"ResponseText": "OK",
"Data": {
    "740300008": "Accounting",
    "740300005": "Advanced Find / Reporting",
    "740300007": "Automation",
    "740300000": "Classes",
    "740300006": "Committees",
    "740300002": "Core",
    "740300003": "Dues",
    "740300001": "Meetings",
    "740300004": "Membership",
    "740300009": "Other"
}

}

To This:

{
"ResponseCode": 200,
"ResponseText": "OK",
"Data": 
	[{
    "740300008": "Accounting"
	},
	{
    "740300005": "Advanced Find / Reporting"
	},
	{
    "740300007": "Automation"
	},
	{
    "740300000": "Classes"
	},
	{
    "740300006": "Committees"
	},
	{
    "740300002": "Core"
	},
	{
    "740300003": "Dues"
	},
	{
    "740300001": "Meetings"
	},
	{
    "740300004": "Membership"
	},
	{
    "740300009": "Other"	
	}]

}

However, I believe the desired format should be this:

{
"ResponseCode": 200,
"ResponseText": "OK",
"Data": 
	[
		{
		"value":"740300008"
		"display":"Accounting"
		}'
		{
		"value":"740300005"
		"display":"Advanced Find / Reporting"
		}'
		{
		"value":"740300007"
		"display":"Automation"
		}'
		{
		"value":"740300000"
		"display":"Classes"
		}'
		{
		"value":"740300006"
		"display":"Committees"
		}'
		{
		"value":"740300002"
		"display":"Core"
		}'
		{
		"value":"740300003"
		"display":"Dues"
		}'
		{
		"value":"740300001"
		"display":"Meetings"
		}'
		{
		"value":"740300004"
		"display":"Membership"
		}'
		{
		"value":"740300009"
		"display":"Other"
		}
	]

}

Is there a plugin that helps one turn these key value pairs into attributes of an object?

If not, I am wondering if I would need to write a custom action to do this.

Yes, you need some custom action for this.
If you need my help please DM me.