2017-04-18 27 views
-3

JSON數據:如何獲得JSON數據如下格式

{"FORM_ID":51393, 
"ORG_ID":1527, 
"REQUEST_ACTION":"ADD", 
"ADD_DATA": 
{ 
    "RECORDS": 
    [ 
     { 
     "ID":"0", 
     "COLUMNS": 
     [ 
      {"NAME":"App Status", "VALUE":"Pending"}, 
      {"NAME":"Remarks","VALUE":"Application in Pending"}, 
      {"NAME":"App Date (dd/MMM/yyyy)" ,"VALUE":"2017-29-03 00:00:00.0"}, 
      {"NAME":"Applicant First Name", "VALUE":"TEST WEBSERVICES First"}, 
      {"NAME":"Applicant Middle Name", "VALUE":"TEST WEBSERVICES Second"}, 
      {"NAME":"Applicant Last Name", "VALUE":"TEST WEBSERVICES Last"}, 
      {"NAME":"Enquiry Center - Walk", "VALUE":"Telephonic"}, 
      {"NAME":"Admission City Office", "VALUE":"TestCity"}, 
      {"NAME":"Applicant Email Id", "VALUE":"[email protected]"}, 
      {"NAME":"Nationality", "VALUE":"testNationality"}, 
      {"NAME":"Country", "VALUE":"INDIA"}, 
      {"NAME":"State", "VALUE":"MAHARASTRA"}, 
      {"NAME":"City", "VALUE":"Mumbai"}, 
      {"NAME":"Permanent Country", "VALUE":"INDIA"}, 
      {"NAME":"Application Seq No", "VALUE":""} 
      {"NAME":"Application Seq No", "Mobile No":"9999999999"} 
     ] 
     } 
    ] 
} 
} 
+4

請顯示你到目前爲止嘗試過 –

回答

0

我不知道什麼是您嘗試這樣做,但如果u有數組

echo json_encode($array); 

如果U試圖讓它來自url

function curl_download($Url){ 

    // is cURL installed yet? 
    if (!function_exists('curl_init')){ 
     die('Sorry cURL is not installed!'); 
    } 

    // OK cool - then let's create a new cURL resource handle 
    $ch = curl_init(); 

    // Now set some options (most are optional) 

    // Set URL to download 
    curl_setopt($ch, CURLOPT_URL, $Url); 

    // Set a referer 
    curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm"); 

    // User agent 
    curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0"); 

    // Include header in result? (0 = yes, 1 = no) 
    curl_setopt($ch, CURLOPT_HEADER, 0); 

    // Should cURL return or print out the data? (true = return, false = print) 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

    // Timeout in seconds 
    curl_setopt($ch, CURLOPT_TIMEOUT, 10); 

    // Download the given URL, and return output 
    $output = curl_exec($ch); 

    // Close the cURL resource, and free system resources 
    curl_close($ch); 

    return $output; 
} 

echo json_encode(curl_download("http://url.com")) ;