Parse json string

I have a API query that returns a result like this:

    "assigned_address": "{\"line1\":\"220 County Road 459\",\"line2\":null,\"city\":\"New Franklin\",\"state\":\"MO\",\"zip\":\"65274\",\"country\":\"US\",\"latitude\":39.03075,\"longitude\":-92.71659}"

The value of "assigned_address" is a JSON result.
How can I parse this stored value into an array and pick out specific fields, like "assigned_address.line1" or ""


var results = JSON.parse(assigned_address)

This should turn your string into a readable JSON object:


would then be your accessible properties.


That answers the question; But I was too vague on my application...
The query returns a result like this:

    "id": 16801,
    "scheduled_datetime": "2024-01-02 09:00",
    "job_type_id": 2,
    "ticket_id": 42824,
    "assigned_type": "accounts",
    "assigned_id": 103498,
    "assigned_name": "abc",
    "assigned_account_type": 1,
    "assigned_address": "{\"line1\":\"2260 State Route P\",\"line2\":\"\",\"city\":\"New Franklin\",\"state\":\"MO\",\"zip\":\"65274\",\"country\":\"US\",\"latitude\":39.03276,\"longitude\":-92.70128}",
    "assigned_contacts": "[{\"id\":1,\"type\":\"mobile\",\"number\":\"111222333444\",\"extension\":null}]",
    "notes": "xyz",
    "status": "completed",
    "user_ids": "62",
    "created_by_user_id": 37,
    "checked_in_user_id": 0,
    "completed_at": "2024-01-02 17:38:41",
    "completed_by_user_id": 62,
    "completed_successfully": 1,
    "completion_reason": "xyz",
    "cause_code": "",
    "jep_code": "",
    "nidcheck": null,
    "nidcheck_result": null

(This is only one result of many)
I am trying to display these in a List Component and list {{item.assigned_name}} and body would include {{', '+item.assigned_address_state}}

Trying to figure out how to properly map these items like this.

In the ListCollection Body, I have:

{{formatDataAsObject(JSON.parse(item.assigned_address).map(obj => ({combined: + ", " + obj.state }))).combined }}

Obviously, I don't know what I'm doing

I'm figured it out:
{{JSON.parse(item.assigned_address).city + ', '+ JSON.parse(item.assigned_address).state}}


Sounds like you know what you're doing after all! :smiley:

1 Like