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

Confusion between commands.Bot and discord.Client | Which one should I use?

Whenever you look at YouTube tutorials or code from this website there is a real variation. Some developers use client = discord.Client(intents=intents) while the others use bot = commands.Bot(command_prefix="something", intents=intents) . Now I know slightly about the difference but I get errors from different places from my code when I use either of them and its confusing. Especially since there has a few changes over the years in discord.py it is hard to find the real difference. I tried sticking to discord.Client then I found that there are more features in commands.Bot . Then I found errors when using commands.Bot . An example of this is: When I try to use commands.Bot client = commands.Bot(command_prefix=">",intents=intents) async def load(): for filename in os.listdir("./Cogs"): if filename.endswith(".py"): client.load_extension(f"Cogs.{filename[:-3]}") The above doesnt giveany response from my Cogs ...

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

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...