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 7570829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:31:02+00:00 2026-05-30T15:31:02+00:00

I am trying to fetch the below json content using a magazine api. The

  • 0

I am trying to fetch the below json content using a magazine api.
The output of the json is like this. i want the below json to convert to php array.

{
"bpath": "http://www.sampledomain.com/",
"clist": [
    {
        "cid": "11",
        "display_type": "grid",
        "ctitle": "abc",
        "acount": "71",
        "alist": [
            {
                "aid": "6865",
                "adate": "2 Hours ago",
                "atitle": "test",
                "adesc": "test desc",
                "aimg": "",
                "aurl": "?nid=6865",
                "weburl": "news.php?nid=6865",
                "cmtcount": "0"
            },

            {
                "aid": "6857",
                "adate": "20 Hours ago",
                "atitle": "test1",
      "adesc": "test desc1",
      "aimg": "",
                "aurl": "?nid=6857",
                "weburl": "news.php?nid=6857",
                "cmtcount": "0"
            }
        ]
    },
    {
        "cid": "1",
        "display_type": "grid",
        "ctitle": "test1",
  "acount": "2354",
        "alist": [
            {
                "aid": "6851",
                "adate": "1 Days ago",
                "atitle": "test123",
      "adesc": "test123 desc",
      "aimg": "",
                "aurl": "?nid=6851",
                "weburl": "news.php?nid=6851",
                "cmtcount": "7"
            },
            {
                "aid": "6847",
                "adate": "2 Days ago",
                "atitle": "test12345",
      "adesc": "test12345 desc",
      "aimg": "",
                "aurl": "?nid=6847",
                "weburl": "news.php?nid=6847",
                "cmtcount": "7"
            }
        ]
    },

]
}

My code looks like this.

<?php 
$json_url = "http://api.testmagazine.com/test.php?type=menu";
$json = file_get_contents($json_url);
$data = json_decode($json, TRUE);
echo "<pre>";
print_r($data);
echo "</pre>";
?>

The above code returns an empty array. 🙁
How is it possible to convert the above JSON to php object array.
I am helpless.

Thanks
Haan

  • 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-30T15:31:03+00:00Added an answer on May 30, 2026 at 3:31 pm

    The JSON sample you provided is not valid. Check it online with this JSON Validator http://jsonlint.com/. You need to remove the extra comma on line 59.

    One you have valid json you can use this code to convert it to an array.

    json_decode($json, true);

    Array
    (
        [bpath] => http://www.sampledomain.com/
        [clist] => Array
            (
                [0] => Array
                    (
                        [cid] => 11
                        [display_type] => grid
                        [ctitle] => abc
                        [acount] => 71
                        [alist] => Array
                            (
                                [0] => Array
                                    (
                                        [aid] => 6865
                                        [adate] => 2 Hours ago
                                        [atitle] => test
                                        [adesc] => test desc
                                        [aimg] => 
                                        [aurl] => ?nid=6865
                                        [weburl] => news.php?nid=6865
                                        [cmtcount] => 0
                                    )
    
                                [1] => Array
                                    (
                                        [aid] => 6857
                                        [adate] => 20 Hours ago
                                        [atitle] => test1
                                        [adesc] => test desc1
                                        [aimg] => 
                                        [aurl] => ?nid=6857
                                        [weburl] => news.php?nid=6857
                                        [cmtcount] => 0
                                    )
    
                            )
    
                    )
    
                [1] => Array
                    (
                        [cid] => 1
                        [display_type] => grid
                        [ctitle] => test1
                        [acount] => 2354
                        [alist] => Array
                            (
                                [0] => Array
                                    (
                                        [aid] => 6851
                                        [adate] => 1 Days ago
                                        [atitle] => test123
                                        [adesc] => test123 desc
                                        [aimg] => 
                                        [aurl] => ?nid=6851
                                        [weburl] => news.php?nid=6851
                                        [cmtcount] => 7
                                    )
    
                                [1] => Array
                                    (
                                        [aid] => 6847
                                        [adate] => 2 Days ago
                                        [atitle] => test12345
                                        [adesc] => test12345 desc
                                        [aimg] => 
                                        [aurl] => ?nid=6847
                                        [weburl] => news.php?nid=6847
                                        [cmtcount] => 7
                                    )
    
                            )
    
                    )
    
            )
    
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to fetch data from a div (based on his id), using PHP's
I am trying to fetch records from the table using the below sql query.
I'm trying to fetch some webpages using the code below: public static string FetchPage(string
hi I am trying to fetch data from link as given below http://abovestress.com/app_stress/fetch_all_detail.php?task=fetchtimefromdateanduserid&track_date=2011-08-09&tracker_user_id=374 but
I'm trying to create a chart using the Google Visualization API, with PHP &
I am trying to fetch the IP address using this:- protected void Page_Load(object sender,
I'm trying to fetch Wikipedia pages using LWP::Simple , but they're not coming back.
I'm trying to fetch the contents of a page using CURL. The page that
I am trying to fetch URLs using Google App Engine's urlFetch service and implement
i am trying to fetch anything that looks like a URL from a string

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.