how to remove/exclude html coding from json file while export?
Question
I have created a file using json and exported it. Its creating HTML tags with it. Actually,I don’t want to have that html part to be there in the file. Below I am sharing structure of my current file: HTML default tags like head,title etc and below is json alon with it.
<html xmlns="http://www.w3.org/1999/xhtml" class="wp-toolbar" lang="en-US">
<!--<![en-->
[{
"ID" : 13,
"post_author" : "1",
"post_date" : "2015-10-30 07:09:16",
"post_date_gmt" : "2015-10-30 07:09:16",
"post_content" : "Test",
"post_title" : "Test",
"post_excerpt" : "",
"post_status" : "publish",
"comment_status" : "closed",
"ping_status" : "closed",
"post_password" : "",
"post_name" : "test",
"to_ping" : "",
"pinged" : "",
"post_modified" : "2015-10-30 07:09:16",
"post_modified_gmt" : "2015-10-30 07:09:16",
"post_content_filtered" : "",
"post_parent" : 0,
"guid" : "url/?post_type=wpcp_pointer&p=9",
"menu_order" : 0,
"post_type" : "wpcp_pointer",
"post_mime_type" : "",
"comment_count" : "0",
"filter" : "raw"
}
]
But what I want is :
[{
"ID" : 13,
"post_author" : "1",
"post_date" : "2015-10-30 07:09:16",
"post_date_gmt" : "2015-10-30 07:09:16",
"post_content" : "Test",
"post_title" : "Test",
"post_excerpt" : "",
"post_status" : "publish",
"comment_status" : "closed",
"ping_status" : "closed",
"post_password" : "",
"post_name" : "test",
"to_ping" : "",
"pinged" : "",
"post_modified" : "2015-10-30 07:09:16",
"post_modified_gmt" : "2015-10-30 07:09:16",
"post_content_filtered" : "",
"post_parent" : 0,
"guid" : "url/?post_type=wpcp_pointer&p=9",
"menu_order" : 0,
"post_type" : "wpcp_pointer",
"post_mime_type" : "",
"comment_count" : "0",
"filter" : "raw"
}
]
Only JSON array to be there file export. Please help how could I remove that html part from json file. Below is the coding part using to generate this code:
$json_file = json_encode($need_options); // Encode data into json data
$json_file = stripslashes($json_file);
echo $json_file;
header("Content-Type: text/json; charset=" . get_option( 'blog_charset'));
header("Content-Disposition: attachment; filename=$json_name.json");
exit();
Any help will be really appriciated.
0
array, jquery, json
3 years
2020-06-04T03:10:19-05:00
2020-06-04T03:10:19-05:00 0 Answers
92 views
0
Leave an answer