Skip to main content

How to get data from json array and object inside json arry from complex json file

I am trying to retrieve data from a json file which having multiple posts using php, I am new to json and can not retrieve each chunk of data from the file, In following json file it has two wordpress post which I want to retrieve but I am not able to retrieve the desire result. because this file is like complex to me and can not get data in jsonarray and jsonobject combination and I am confuse with that combination, Any help from respectable gurus will be highly appreciated.

[
  {
 "id": 5758,
 "date": "2021-06-23T19:49:30",
 "date_gmt": "2021-06-23T14:49:30",
 "guid": {
  "rendered": "http://mydoman.com/?p=5758"
},
"modified": "2021-06-23T19:49:38",
"modified_gmt": "2021-06-23T14:49:38",
"slug": "itisaslug",
"status": "publish",
"type": "post",
"link": "http://mydoman.com/short-stories/story/",
"title": {
"rendered": "it is a title"
},
"content": {
"rendered": "<p>Story is Short Story written by Writer name the social issue <!--more--><br 
/>\n<img loading=\"lazy\" src=\"http://mydoman.com/mydomanstorier/Writername/storyimage- 
1.gif\" width=\"499\" height=\"699\" alt=\"It is a alt text here, Page No.  1\">  <!-- 
nextpage--><br />\n<img loading=\"lazy\" 
src=\"http://mydoman.com/stories/writer/Storyimage-2.gif\" width=\"499\" height=\"699\" 
alt=\"Alt text here, Page No.  2\">  <!--nextpage--><br />\n<img loading=\"lazy\" 
src=\"http://mydoman.com/stories/writer/storyimage-3.gif\" width=\"499\" height=\"699\" 
alt=\"alt text here , Page No.  3\"></p>\n",
"protected": false
},
"excerpt": {
"rendered": "<p>excerpt text here</p>\n",
"protected": false
},
"author": 10,
"featured_media": 5759,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"template": "",
"format": "standard",
"meta": [],
"categories": [
 4
],
"tags": [
479,
507,
212,
177,
179,
296
],
"jetpack_featured_media_url": "http://mydoman.com/wp-content/uploads/2021/06/featureimage-1.gif",
"_links": {
"self": [
{
 "href": "http://mydoman.com/wp-json/wp/v2/posts/5758"
}
],
"collection": [
{
 "href": "http://mydoman.com/wp-json/wp/v2/posts"
 }
],
"about": [
{
 "href": "http://mydoman.com/wp-json/wp/v2/types/post"
}
],
"author": [
{
"embeddable": true,
 "href": "http://mydoman.com/wp-json/wp/v2/users/10"
}
],
"replies": [
 {
"embeddable": true,
 "href": "http://mydoman.com/wp-json/wp/v2/comments?post=5758"
 }
 ],
"version-history": [
{
"count": 0,
"href": "http://mydoman.com/wp-json/wp/v2/posts/5758/revisions"
}
],
"wp:featuredmedia": [
{
"embeddable": true,
"href": "http://mydoman.com/wp-json/wp/v2/media/5759"
}
],
"wp:attachment": [
{
"href": "http://mydoman.com/wp-json/wp/v2/media?parent=5758"
}
],
"wp:term": [
{
"taxonomy": "category",
"embeddable": true,
"href": "http://mydoman.com/wp-json/wp/v2/categories?post=5758"
},
{
"taxonomy": "post_tag",
 "embeddable": true,
 "href": "http://mydoman.com/wp-json/wp/v2/tags?post=5758"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
},
{
"id": 5684,
"date": "2021-06-20T13:10:01",
"date_gmt": "2021-06-20T08:10:01",
"guid": {
"rendered": "http://mydoman.com/?p=2345"
},
"modified": "2021-06-20T13:10:07",
"modified_gmt": "2021-06-20T08:10:07",
"slug": "set-up",
"status": "publish",
"type": "post",
"link": "http://mydoman.com/postlink-1/",
"title": {
"rendered": "this is a title"
},
"content": {
"rendered": "<p>It is a crime story written by writer name <!--more--></p>\n<p><img             
loading=\"lazy\" src=\"http://mydoman.com/upload/image-1.gif\" width=\"499\" height=\"699\"     
alt=\"alt text, Page No.  1\">  <!--nextpage--><br />\n<img loading=\"lazy\" 
src=\"http://mydoman.com/upload/image-2.gif\" width=\"499\" height=\"699\" alt=\"alt text 2, 
 Page No.  2\">  <!--nextpage-->",
"protected": false
},
"excerpt": {
"rendered": "<p>excerpt text by the writer</p>\n",
"protected": false
},
"author": 10,
"featured_media": 5685,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"template": "",
"format": "standard",
"meta": [],
"categories": [
39
],
"tags": [
532,
195,
533,
91
],
"jetpack_featured_media_url": "http://mydoman.com/wp-content/uploads/2021/05/feature-image-url-1.gif",
"_links": {
"self": [
{
"href": "http://mydoman.com/wp-json/wp/v2/posts/5684"
}
],
"collection": [
{
"href": "http://mydoman.com/wp-json/wp/v2/posts"
}
],
"about": [
{
"href": "http://mydoman.com/wp-json/wp/v2/types/post"
}
],
"author": [
{
"embeddable": true,
"href": "http://mydoman.com/wp-json/wp/v2/users/10"
}
],
"replies": [
{
"embeddable": true,
"href": "http://mydoman.com/wp-json/wp/v2/comments?post=5684"
}
],
"version-history": [
{
"count": 0,
 "href": "http://mydoman.com/wp-json/wp/v2/posts/5684/revisions"
}
],
"wp:featuredmedia": [
{
"embeddable": true,
"href": "http://mydoman.com/wp-json/wp/v2/media/5685"
}
],
"wp:attachment": [
{
 "href": "http://mydoman.com/wp-json/wp/v2/media?parent=5684"
}
],
"wp:term": [
{
"taxonomy": "category",
 "embeddable": true,
 "href": "http://mydoman.com/wp-json/wp/v2/categories?post=5684"
 },
 {
 "taxonomy": "post_tag",
 "embeddable": true,
 "href": "http://sohnidigest.com/wp-json/wp/v2/tags?post=5684"
 }
 ],
 "curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
 "templated": true
}
]
}
}
]


source https://stackoverflow.com/questions/68958278/how-to-get-data-from-json-array-and-object-inside-json-arry-from-complex-json-fi

Comments

Popular posts from this blog

Where and how is this Laravel kernel constructor called? [closed]

Where and how is this Laravel kernel constructor called? public fucntion __construct(Application $app, $Router $roouter) { } I have read the documentation and some online tutorial but I can find any clear explanation. I am learning Laravel and I am wondering where does this kernel constructor receives its arguments from. "POSTMOTERM" CLARIFICATION: Here is more clarity.I have checked the boostrap/app.php and it is only used for boostrapping the interfaces into the container class. What is not clear to me is where and how the Kernel class is instatiated and the arguments passed to the object calling the constructor.Something similar to; obj = new kernel(arg1,arg2) or, is the framework using some magic functions somewhere? Special gratitude to those who burn their eyeballs and brain cells on this trivia before it goes into a full blown menopause alias "MARKED AS DUPLICATE". To some of the itchy-finger keyboard warriors, a.k.a The mods,because I believe in th...

Why is my reports service not connecting?

I am trying to pull some data from a Postgres database using Node.js and node-postures but I can't figure out why my service isn't connecting. my routes/index.js file: const express = require('express'); const router = express.Router(); const ordersCountController = require('../controllers/ordersCountController'); const ordersController = require('../controllers/ordersController'); const weeklyReportsController = require('../controllers/weeklyReportsController'); router.get('/orders_count', ordersCountController); router.get('/orders', ordersController); router.get('/weekly_reports', weeklyReportsController); module.exports = router; My controllers/weeklyReportsController.js file: const weeklyReportsService = require('../services/weeklyReportsService'); const weeklyReportsController = async (req, res) => { try { const data = await weeklyReportsService; res.json({data}) console...

How to show number of registered users in Laravel based on usertype?

i'm trying to display data from the database in the admin dashboard i used this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count(); echo $users; ?> and i have successfully get the correct data from the database but what if i want to display a specific data for example in this user table there is "usertype" that specify if the user is normal user or admin i want to user the same code above but to display a specific usertype i tried this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count()->WHERE usertype =admin; echo $users; ?> but it didn't work, what am i doing wrong? source https://stackoverflow.com/questions/68199726/how-to-show-number-of-registered-users-in-laravel-based-on-usertype