I have a table which has two columns, id(primary) and itinerary(jsonb) which the second column's data type is jsnob. My query which is shown below is working fine.

SELECT itinerary FROM tbl WHERE id = $x;

The query result I get in controller shows the data type as object. If I encode it with json_encode() the data type shown is string. Well, my resuirment is, I want this query result in json format in my view. Sample query result is shown below:

stdClass Object
    [tour_itinerary] => [{"day": "Day One: Delhi – Nainital", "itinerary": "On reaching Delhi, meet our IHPL representative who will help you take a transfer to Nainital. En-route visit Gajraula which is well-known for its tourist destinations such as Najibudaulah’s Fort, Mandawar Ka Mahal and Raza library. After arriving in Nainital, check-in to the hotel. Nainital is a beautiful place which promises to calm your senses. Enjoy the day at any of the scenic locations of the place and relax yourself in a comfortable and calming atmosphere."}, {"day": "Day Two: Nainital - Bhimtal - Sattal- Nainital", "itinerary": "You can begin this morning with a visit to the Cheena Peak which offers a breathtaking panoramic view of the Himalayas. Spend rest of the day with a trip to Bhimtal and Sattal. Bhimtal is a scenic lakeside destination which offers a soothing environment to all the visitors.\r\n\r\nSattal is a place where seven lakes come together. The place is surrounded by beautiful green scenery. In the evening, return to Nainital and enjoy shopping at the mall road. Have a comfortable stay at night."}]

Quick help will be very much appreciated.

0 Answers