Extracting Nested JSON values

Hello, I am working on a workflow that receives text in the following format:

{
  "goal": "CS229 Problem Set #2",
  "due_date": "October 25 at 11:59 pm",
  "class_name": "CS 229",
  "monday": [
    {
      "Action": "Review assignment requirements",
      "Start time": "10:00",
      "Duration": "30 min",
      "Impact": "Clarify expectations for tasks"
    },
    {
      "Action": "Complete questions 1 and 2",
      "Start time": "10:30",
      "Duration": "1 hr",
      "Impact": "Progress on part of the assignment"
    }
  ],
  "tuesday": [
    {
      "Action": "Review assignment requirements",
      "Start time": "10:00",
      "Duration": "30 min",
      "Impact": "Clarify expectations for tasks"
    },
    {
      "Action": "Complete questions 1 and 2",
      "Start time": "10:30",
      "Duration": "1 hr",
      "Impact": "Progress on part of the assignment"
    }
  … (and so on for every day)
  "friday": [
    {
      "Action": "Test code from questions 3 and 4",
      "Start time": "2:00",
      "Duration": "1 hr",
      "Impact": "Validate functionality of implementations"
    },
    {
      "Action": "Review and compile the entire assignment for submission",
      "Start time": "3:00",
      "Duration": "1 hr",
      "Impact": "Preparation for a successful submission"
    }
  ]
}

I would like to add all of these values to my database. I currently have a Task object that has fields Goal, Due date, Class name and a list that will contain objects of type Day, with fields Day name and a list Actions that has fields Action, Start time, Duration, and Impact.
I have tried many solutions, such as plugins and backend APIs, but all seem to come short. What’s the problem?

Can you show the API connector setting from where you get this json?


So above, the result of Boostability Assistant – List Messages is a text output that is formatted as a JSON. Maybe I should do something in there to better parse the information? So basically I’m taking that text output then trying to parse the individual values.

And above is the result of my API call, as you can see text value is setting the resulting JSON just to text, and I am unable to edit it’s type to something recognizable by a JSON.

Can you initialize the API for the actual response as mentioned by you, instead of text value : 1

Once you you do that, you would be able to parse the JSON properly.

Ah, so you mean to say, that within the Text value parameter in the API response, you get something like

{
  "goal": "CS229 Problem Set #2",
  "due_date": "October 25 at 11:59 pm",
  "class_name": "CS 229",
  "monday": [
    {
      "Action": "Review assignment requirements",
      "Start time": "10:00",
      "Duration": "30 min",
      "Impact": "Clarify expectations for tasks"
    },
    {
      "Action": "Complete questions 1 and 2",
      "Start time": "10:30",
      "Duration": "1 hr",
      "Impact": "Progress on part of the assignment"
    }
  ],
  "tuesday": [
    {
      "Action": "Review assignment requirements",
      "Start time": "10:00",
      "Duration": "30 min",
      "Impact": "Clarify expectations for tasks"
    },

and so on...

So, you basically need a way to extract this, and parse it as a JSON?

Yes exactly. The text value parameter gives that JSON, and I need a way to extract all of these values and put them in my database to be used in my app.

This is with the actual response mentioned. As you can see, the value for text value is { (open bracket) followed by \n since it is a JSON. So we cannot see the full text but it is of the form as described in the original post.

@laughlincalvin Got it.

Might not be the best solution but you can try this.

  1. Set the API to use as Action (Not Data) (Eg. Get Schedule Data)
  2. Setup a new API workflow
  3. Add an action to call the API (Get Schedule Data)
  4. Add another action after (From step 3), Return Data from API (Refer Screenshot)
  5. Call the New API workflow (From step 2) from the API connector, this time in the initialise response, Bubble will automatically parse the JSON (schedule data) with respective data types.

@laughlincalvin Let me know if that helps.

I think I understand what you’re saying, but I’m not quite sure I’m doing it correctly.
Below is my API workflow with my Action call to retrieve the messages (Step 1 will return text as a JSON I described in the original post). I believe I am passing that value into Return data from API.


However when I run it live I run into this bizarre outcome:
As you can see below, the result of me calling Schedule API workflow results in just the number 76.

Below is my workflow where I am scheduling the API workflow. I am passing it to a Bubble thing just for testing at the moment.

Not sure what I’m doing wrong.

You have missed to call the API workflow from the API connector. Try it. That should give you what you are looking for.

That is just schedule workflow ID. Not the actual response. To get the actual response, do the step 5.