Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3978306
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:01:53+00:00 2026-05-20T05:01:53+00:00

I’m trying to convert a JSON object/array from the Google Directions API v3 to

  • 0

I’m trying to convert a JSON object/array from the Google Directions API v3 to PHP so I can store it in a MySQL Database.

The array looks something like this (I truncated it pretty heavily…sorry for making it so long…I guess this is also an informative question for people wanting to know what the array string from Google Directions looks like):

{
"status":"OK",
"routes":[{
    "summary":"Lakelands Trail State Park",
    "legs":[{
        "steps":[{
            "travel_mode":"BICYCLING",
            "start_location":{"za":42.73698,"Ba":-84.4838},
            "end_location":{"za":42.74073,"Ba":-84.48378},
            "polyline":{"points":"cazcGvvsbOmVC","levels":"BB"},
            "duration":{"value":68,"text":"1 min"},
            "distance":{"value":417,"text":"0.3 mi"},
            "encoded_lat_lngs":"cazcGvvsbOmVC",
            "path":[{"za":42.73698,"Ba":-84.4838},{"za":42.740730000000006,"Ba":-84.48378000000001}],
            "lat_lngs":[{"za":42.73698,"Ba":-84.4838},{"za":42.740730000000006,"Ba":-84.48378000000001}],
            "instructions":"Head north on Abbot Rd toward Elizabeth St",
            "start_point":{"za":42.73698,"Ba":-84.4838},
            "end_point":{"za":42.74073,"Ba":-84.48378}
        },{ 
                    //more steps go here
//end steps array
}}],

        "duration":{"value":12309,"text":"3 hours 25 mins"},
        "distance":{"value":66198,"text":"41.1 mi"},
        "start_location":{"za":42.66069,"Ba":-84.07321},
        "end_location":{"za":42.27668,"Ba":-83.74076},
        "start_address":"E Grand River Ave, Fowlerville, MI 48836, USA",
        "end_address":"angell hall, 435 S State St, Ann Arbor, MI 48109, USA",
        "via_waypoint":[]
        //end leg array
        }],

"copyrights":"Map data ©2011 Google",
"warnings":["Bicycling directions are in beta. Use caution – This route may contain streets that aren't suited for bicycling."],
"waypoint_order":[0],
"bounds":{"U":{"b":42.276680000000006,"d":42.740840000000006},"O":{"d":-84.4838,"b":-83.73996000000001}},
"optimized_waypoint_order":[0]}],
"Ef":{"origin":"east lansing, mi","destination":"1139 Angell Hall 435 S. State Street Ann Arbor, MI 48109",
"waypoints":[{"location":"Bloated Goat Saloon, East Grand River Avenue, Fowlerville, MI","stopover":true}],"optimizeWaypoints":false,"travelMode":"BICYCLING"}

Using AJAX, I sent this object to PHP to decode it and save it in a database.

The only problem is that I don’t know how to parse the JSON into PHP…I kind of feel like a dog that actually caught the car they were chasing…I don’t know what to do next.

So my question:
How do I take the array above and turn it into something PHP can send to a MySQL database (I already have the database structure set up)? I’m not very good with programming languages, so if you could write your response in the most basic way possible, I’d be ever so grateful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:01:54+00:00Added an answer on May 20, 2026 at 5:01 am

    You could just store the JSON string directly in the database in a text field.

    Alternately, if you want to read the individual fields in PHP, use the json_decode function to turn the JSON string into a PHP array.

    http://php.net/manual/en/function.json-decode.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.