The Slim Framework support forum has moved to http://discourse.slimframework.com. This Tender forum is no longer maintained or monitored.

nested array in json response

John H's Avatar

John H

19 Apr, 2013 07:18 PM

I have a json response that looks like:

{
   "name":"john",
   "city":"pittsburgh",
   "fav_things":[
      {
         "first_color":"blue",
         "second_color":"green",
         "third_color":"white"
      },
      {
         "fourth_color":"black",
         "fifth_color":"orange",
         "sixth_color":"brown"
      }
   ],
   "active":true
}

As you can see, the fav_things property is a nested array.

Up until now, I have had no problems with single properties updating in my database using Slim. I'm stuck on how to best update this array of properties as ONE into a row on my mysql db.

The error message I receive when Slim tries to accept this response and update the db is:

Type: ErrorException Code: 8
Message: Array to string conversion

How can I instruct Slim or my mysql code to interpret this nested array correctly?

my current code looks like

$sql = "UPDATE users SET
name=:name,
city=:city,
fav_things=:fav_things,
active=:active,
WHERE id=:id

$request = $app->request();
$response = $request->getBody();
$response = json_decode($response);

$STH  = $db->prepare($sql);
$STH->bindParam("name", $response->name);
$STH->bindParam("name", $response->city);
$STH->bindParam("name", $response->fav_things);
$STH->bindParam("name", $response->active);
$STH->execute();

Can anyone help me figure out how to get this fav_things nested property working?

Thanks! Any help is much appreciated!

John

Showing page 2 out of 3. View the first page

  1. 31 Posted by mobdro apk on 28 Jun, 2016 01:44 PM

    mobdro apk's Avatar
  2. 32 Posted by gameguardian ap... on 28 Jun, 2016 01:45 PM

    gameguardian apk's Avatar
  3. 33 Posted by flappybird apk on 28 Jun, 2016 01:46 PM

    flappybird apk's Avatar
  4. 34 Posted by messy on 01 Jul, 2016 11:33 AM

    messy's Avatar

    It is web address of playststion codes free of cost. http://free-psncodesonline.com

  5. 35 Posted by ram on 09 Jul, 2016 09:52 AM

    ram's Avatar
  6. 36 Posted by ADas on 27 Jul, 2016 01:31 PM

    ADas's Avatar

    This is a relevant article. I really appreciate your work. Thanks a lot. Also see MP3 Download Sites@ http://www.techvicity.com/2016/05/free-mp3-download-sites-music-apps.html

  7. 37 Posted by nikky on 30 Jul, 2016 08:29 AM

    nikky's Avatar

    Travel between the real world and the virtual world of Pokémon with Pokémon GO for iPhone and Android devices .

  8. 38 Posted by SHAREit for PC on 06 Aug, 2016 07:30 AM

    SHAREit for PC's Avatar

    SHAREit is an app that allows you to share files between your devices. Download SHAREit for Windows PC http://www.shareitforwindowspc.com/

  9. 39 Posted by SBI PO Mains Re... on 07 Aug, 2016 02:39 PM

    SBI PO Mains Results 2016's Avatar
  10. 40 Posted by SHAREit for PC on 22 Aug, 2016 10:24 AM

    SHAREit for PC's Avatar

    lenovo SHAREit for PC is the best solution to transfer data from one to another device. Download SHAREit for PC http://www.shareitforwindowspc.com/

  11. 41 Posted by SHAREit for PC on 29 Aug, 2016 11:05 AM

    SHAREit for PC's Avatar

    Using Shareit for PC doesn't require any Internet connection or Wi- Fi setting. Download SHAREit for Windows PC http://www.shareitforwindowspc.com/

  12. 42 Posted by 1commvibmir on 31 Aug, 2016 01:48 AM

    1commvibmir's Avatar

    It is really difficult for me to understand about nested loops. Vibrational Manifestation eBook

  13. 43 Posted by Nasir on 31 Aug, 2016 09:50 AM

    Nasir's Avatar

    It's very difficult to apply nested loops. I got sever queries related to it on my site http://hseionline.com/

  14. 44 Posted by 1commmanmir on 01 Sep, 2016 03:41 AM

    1commmanmir's Avatar
  15. 45 Posted by musicparadise on 08 Sep, 2016 10:31 AM

    musicparadise's Avatar

    thank you soo much creating this awesome website. I like it ! music paradise pro(http://smugglersmusic.com/) and also i am working on xender download(
    http://xenderapkdownload.com/) keep creating work like this.

  16. 46 Posted by SHAREit for PC on 09 Sep, 2016 10:27 AM

    SHAREit for PC's Avatar

    SHAREit is a FREE file sharing app that works across multiple operating systems. Download SHAREit for Windows PC http://www.shareitforwindowspc.com/

  17. 47 Posted by SHAREit for PC on 20 Sep, 2016 08:51 AM

    SHAREit for PC's Avatar

    lenovo SHAREit for PC is the best solution to transfer data from one to another device. Download SHAREit for PC http://www.shareitforwindowspc.com/

  18. 48 Posted by nipizaye on 22 Sep, 2016 06:05 AM

    nipizaye's Avatar

    Your computer is give notification to update your drivers.
    http://redsmoothiedetoxfactorliz.com/

  19. 49 Posted by wetuliva on 23 Sep, 2016 05:05 AM

    wetuliva's Avatar
  20. 50 Posted by SHAREit for PC on 01 Oct, 2016 09:01 AM

    SHAREit for PC's Avatar

    Download SHAREit for PC or Computer on Windows 7/8.1/10. Download SHAREit for PC http://www.shareitforwindowspc.com/

  21. 51 Posted by JohnyMn on 02 Oct, 2016 06:35 AM

    JohnyMn's Avatar

    Home Based Business Vs Work Both At Home - What Are The Differences?

    http://go.1o3.me/DsX6T - staffing agencies

  22. 52 Posted by SHAREit for PC on 20 Oct, 2016 09:49 AM

    SHAREit for PC's Avatar

    SHAREit is a FREE file sharing app that works across multiple operating systems. Download SHAREit for PC http://www.shareitforwindowspc.com/

  23. 53 Posted by rumocixi on 21 Oct, 2016 02:59 AM

    rumocixi's Avatar

    This property is rented out to a bank manager. https://realonlinereview.com/erectile-booster-method/

  24. 54 Posted by SHAREit for PC on 28 Oct, 2016 11:15 AM

    SHAREit for PC's Avatar

    Shareit is the best file sharing application. Download SHAREit for PC http://www.shareitforwindowspc.com/

  25. 55 Posted by SHAREit for PC on 01 Nov, 2016 09:14 AM

    SHAREit for PC's Avatar

    Download SHAREit for PC or Computer on Windows 7/8.1/10. Download SHAREit for PC http://www.shareitforwindowspc.com/

  26. 56 Posted by wzrur on 25 Nov, 2016 07:12 AM

    wzrur's Avatar

    I am having lots of problems in json. Please help me.How to Make Your Dick Bigger Naturally

  27. 57 Posted by iuj on 27 Nov, 2016 07:19 AM

    iuj's Avatar

    This nested array in json is creating lot of problem to me.
    Hard on Demand Reviews

  28. 58 Posted by yfa on 28 Nov, 2016 03:44 AM

    yfa's Avatar

    I hate working with nested array in any programming language.
    Penis Enlargement Bible Program

  29. 59 Posted by Glean on 03 Dec, 2016 05:16 AM

    Glean's Avatar

    Great as today we are here with among the most remarkable https://tutuappdownloadz.com yet is much more than that. Fine.

  30. 60 Posted by whitegeorge3201 on 02 Jan, 2017 10:24 AM

    whitegeorge3201's Avatar

    good so you could simply download it.Artisto is truly https://artistoappdownload.com/artisto-apk-download-for-android to make use of, except, obviously, enabling it to access best.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac