Separate content from Response Content

Using a Json:
[{“plate_num”:“30”,“b_class”:“Class 3 Unit”,“b_dep”:“9:30”,“b_arriv”:“11:30”,“b_driv”:“Arnel Ignacio”},
{“plate_num”:“20”,“b_class”:“Class 5 Unit”,“b_dep”:“8:30”,“b_arriv”:“12:30”,“b_driv”:“Juan Pedro”}]
and Lookup Pairs Key Block

:point_up:

4 Likes

The Do It is not working for me idk y :cold_sweat:

Connect to Companion…
Check your JSON return from your PHP :

my companion always stops, I’m just using an emulator

:point_down:

I already adjusted that blocks awhile ago this is now my current blocks:


and I always got this:

Did you check your Json here ?
:point_down:

can you share your AIA? post it here or at least share your API endpoint

Yes and this is the result:

{
   "bus":[
      {
         "Bus_Plate_Number":"30",
         "Bus_Class":"Class 3 Unit",
         "Bus_Branch":"Calbayog",
         "Bus_Route":"Allen",
         "Bus_Dep_Time":"9:30 AM",
         "Bus_Arriv_Time":"11:30 AM",
         "Bus_Driver":"Arnel Ignacio",
         "Bus_Contact":"09123456789",
         "Bus_DateAdded":"2021-08-07"
      }
   ]
}{
   "bus":[
      {
         "Bus_Plate_Number":"30",
         "Bus_Class":"Class 3 Unit",
         "Bus_Branch":"Calbayog",
         "Bus_Route":"Allen",
         "Bus_Dep_Time":"9:30 AM",
         "Bus_Arriv_Time":"11:30 AM",
         "Bus_Driver":"Arnel Ignacio",
         "Bus_Contact":"09123456789",
         "Bus_DateAdded":"2021-08-07"
      },
      {
         "Bus_Plate_Number":"35",
         "Bus_Class":"Class 3 Unit",
         "Bus_Branch":"Calbayog",
         "Bus_Route":"Allen",
         "Bus_Dep_Time":"9:30 AM",
         "Bus_Arriv_Time":"11:30 AM",
         "Bus_Driver":"Efren Catalan",
         "Bus_Contact":"09123456789",
         "Bus_DateAdded":"2021-08-07"
      }
   ]
}

This is not a valid json

2 Likes

you need to make some changes in your php code for generating valid json.

1 Like

I already warned you about this…
I’ve already shown you the topic about JSON…
Showed the link to test JSON…

But it seems that the users here on the forum want to solve it in a few minutes…

4 Likes

Sorry, the app that I’m generating right now is part of my thesis that’s why I’m really eager to solve the problem quickly. I’m currently adjusting the php file right now. This JSON is really new to me that’s why I always got this error since last week.

(post deleted)

Already Rogerio shared a site . Please make use of it and correct your json

What he needs is to adjust the php script that generates the JSON.

2 Likes

I already knew what’s the valid json. The only problem is how I will correct it through php. This is my code:

$conn = new mysqli($host,$username,$password,$dbname);
$data = mysqli_query($conn, "SELECT * FROM bus WHERE Bus_Dep_Time='9:30 AM' AND Bus_Branch='Calbayog'");
$array = array();
while ($result=mysqli_fetch_assoc($data))
{
    $array['bus'][]=$result;
    echo json_encode($array);
}

I keep adjusting the $array[‘bus’]=$result; but I always got the wrong json

I got it, i got it…

:point_down:

From search in GOOGLE …

1 Like

It made some change. try it

$conn = new mysqli($host,$username,$password,$dbname);
$data = mysqli_query($conn, "SELECT * FROM bus WHERE Bus_Dep_Time='9:30 AM' AND Bus_Branch='Calbayog'");
$array = array();
while ($result=mysqli_fetch_assoc($data))
{
    $array[]['bus'][]=$result;
}
echo json_encode($array);
3 Likes

omg you got it! :scream:

1 Like