如何使用php pdo创建JSON嵌套对象

zxlwwiss  于 2023-04-19  发布在  PHP
关注(0)|答案(3)|浏览(106)

我已经检查了大多数相关的答案在这里的stackoverflow,但找不到什么适合我的情况。
任何友好的答复将不胜感激。
我使用PHPPDO从两个名为comments和comments_reply的mysql表中获取数据,值如下
注解表

  • 注解ID
  • 新闻ID
  • 注解名称
  • 评论日期

注解回复表

  • 回复ID
  • 注解ID
  • 回复名称
  • 答复
  • 答复日期

我返回空数组作为结果,而不是像这样的JOSN格式的结果:

[
   {"id": 1,
    "comment_date": "2017-08-09",
    "comment_time": "06:10:00",
    "names": "Imenwo Alex",
    "img": "c1.jpg",
    "comments": "<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,There are many variations of passages of Lorem Ipsum available, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,There are many variations of passages of Lorem Ipsum available, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>",
    "replies":[
        {
                 "id": 1,
                "reply_date": "2017-08-09",
                "reply_time": "06:10:00",
                "names": "frank Alex",
                "img": "c1.jpg",
                "reply": "<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,There are many variations of passages of Lorem Ipsum available, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,There are many variations of passages of Lorem Ipsum available, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>"
            },
            {
                 "id": 2,
                "reply_date": "2017-08-09",
                "reply_time": "06:10:00",
                "names": "frank Alex",
                "img": "c1.jpg",
                "reply": "<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,There are many variations of passages of Lorem Ipsum available, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,There are many variations of passages of Lorem Ipsum available, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>"
            }
    ]
    },
    {"id": 2,
    "comment_date": "2017-08-09",
    "comment_time": "06:10:00",
    "names": "Imenwo Alex",
    "img": "c1.jpg",
    "comments": "<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,There are many variations of passages of Lorem Ipsum available, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,There are many variations of passages of Lorem Ipsum available, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>",
    "replies":[
            {
                 "id": 1,
                "reply_date": "2017-08-09",
                "reply_time": "06:10:00",
                "names": "frank Alex",
                "img": "c1.jpg",
                "reply": "<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,There are many variations of passages of Lorem Ipsum available, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,There are many variations of passages of Lorem Ipsum available, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>"
            }
        ]
    }
]

下面是我的PHP脚本:

//
      $q = "SELECT * FROM comments WHERE comments.news_id =:id";         
      //prepare
      $stmt = $this->DB_con->prepare($q);
      //bind parameters
      $stmt->bindParam(':id', $id);

      //create an array
      $json_response = array(); 
      while($obj=$stmt->fetch(PDO::FETCH_OBJ)) {

          $currentComments = array(
              'id' => $obj->comment_id,
              'comment_names' => $obj->comment_names,
              'comment_date' => $obj->comment_date,
              'comment_time' => $obj->comment_time,
              'comment_img' => $obj->comment_img,
              'comments' => $obj->comments,
              'replies' => array()
          );

          //
          $r = "SELECT * FROM comments_reply WHERE comments_reply.comment_id =:id"; 
          //prepare
          $stmt = $this->DB_con->prepare($r);
          //bind parameters
          $stmt->bindParam(':id', $obj->comment_id);
          while($obj=$stmt->fetch(PDO::FETCH_OBJ)) {

              $currentComments['replies'][] = array(
                  'id' => $obj->reply_id,
                  'reply_names' => $obj->reply_names,
                  'reply_date' => $obj->reply_date,
                  'reply_time' => $obj->reply_time,
                  'reply_img' => $obj->reply_img,
                  'reply' => $obj->reply
              );

          }
          array_push($json_response, $currentComments); //push the values in the array

      }
      return json_encode($json_response);
syqv5f0l

syqv5f0l1#

不要覆盖$stmt和$obj。类似这样:

$q = "SELECT * FROM comments WHERE comments.news_id =:id";         
      //prepare
      $stmt = $this->DB_con->prepare($q);

      $r = "SELECT * FROM comments_reply WHERE comments_reply.comment_id =:id"; 
      //prepare
      $stmt2 = $this->DB_con->prepare($r);

      //execute with bound parameter
      $stmt->execute( array(':id'=> $id));

      //create an array
      $json_response = array(); 

      while($obj=$stmt->fetch(PDO::FETCH_OBJ)) {

          $currentComments = array(
              'id' => $obj->comment_id,
              'comment_names' => $obj->comment_names,
              'comment_date' => $obj->comment_date,
              'comment_time' => $obj->comment_time,
              'comment_img' => $obj->comment_img,
              'comments' => $obj->comments,
              'replies' => array()
          );

          //
          $stmt2->execute( array(':id'=> $obj->comment_id) );

          while($obj2=$stmt2->fetch(PDO::FETCH_OBJ)) {

              $currentComments['replies'][] = array(
                  'id' => $obj2->reply_id,
                  'reply_names' => $obj2->reply_names,
                  'reply_date' => $obj2->reply_date,
                  'reply_time' => $obj2->reply_time,
                  'reply_img' => $obj2->reply_img,
                  'reply' => $obj2->reply
              );

          }
          array_push($json_response, $currentComments); //push the values in the array

      }
      return json_encode($json_response);
q43xntqr

q43xntqr2#

你也可以在MySQL中这样做,为了保持简短,你可以这样做:

SELECT json_arrayagg(json_object(
  'id',x.comment_id,
  'comment_date',date(x.comment_date),
  'comment_time',time(x.comment_date),
  'replies',x.cr
  )) as JSON
FROM (
SELECT 
  c.*, 
  (
  SELECT json_arrayagg(json_object(
      'id',cr.comment_id,
      'reply_date',date(cr.reply_date),
      'reply_time',time(cr.reply_date)
     ))
  FROM comments_reply cr
  WHERE cr.comment_id = c.comment_id
  ) cr
FROM comments c
WHERE c.news_id = 1
) x

有关完整的(或更完整的😉)SQL,请参阅DBFIDDLE
结果:

[
    {
        "id": 1,
        "names": "Comment1",
        "replies": [
            {
                "id": 1,
                "names": "ReplyName1",
                "reply": "Reply1",
                "reply_date": "2023-01-01",
                "reply_time": "00:00:00.000000"
            }
        ],
        "comments": "This is the first comment",
        "comment_date": "2023-01-01",
        "comment_time": "10:00:00.000000"
    },
    {
        "id": 2,
        "names": "Comment2",
        "replies": [
            {
                "id": 2,
                "names": "ReplyName2",
                "reply": "Reply2",
                "reply_date": "2023-01-02",
                "reply_time": "00:00:00.000000"
            }
        ],
        "comments": "This is the second comment",
        "comment_date": "2023-01-02",
        "comment_time": "11:00:00.000000"
    },
    {
        "id": 3,
        "names": "Comment3",
        "replies": [
            {
                "id": 3,
                "names": "ReplyName3",
                "reply": "Reply3",
                "reply_date": "2023-01-03",
                "reply_time": "00:00:00.000000"
            }
        ],
        "comments": "This is the third comment",
        "comment_date": "2023-01-03",
        "comment_time": "12:00:00.000000"
    }
]
dgsult0t

dgsult0t3#

在第二个循环中,你必须使用array_push和另一个数组--类似这样。

$product_group = array();
$product_figure = array();
$name_product_figure = array();
$query = "SELECT * FROM product_group";
$res = $connection->prepare($query);
$res->execute();
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
    $record = array();
    $id_product_figure = array();
    $name_product_figure = array();
    $record["id_product_class"] = $row["id_product_class"];
    $record["id_product_group"] = $row["id_product_group"];
    $record["name_product_group"] = $row["name_product_group"];
    $record["product_figure"] = array();

    $query2 = "SELECT product_tbl_groupfigur.id_product_tbl_groupfigur ,
product_figures.id_product_figure,product_figures.name_product_figure
FROM product_tbl_groupfigur
JOIN product_figures
ON product_tbl_groupfigur.id_product_figure=product_figures.id_product_figure
WHERE product_tbl_groupfigur.id_product_group=:id_pro_group";

    $res2 = $connection->prepare($query2);
    $res2->bindParam(":id_pro_group", $row["id_product_group"]);
    $res2->execute();
    while ($row2 = $res2->fetch(PDO::FETCH_ASSOC)) {
        $record2 = array();
        //   $id_product_figure[]=$row2["id_product_figure"];
        // $name_product_figure[]=$row2["name_product_figure"];
        $record2["id_product_figure"] = $row2["id_product_figure"];
        $record2["name_product_figure"] = $row2["name_product_figure"];
        array_push($record["product_figure"], $record2);
    }

    array_push($product_group, $record);

}

echo json_encode($product_group);
[
{
    "id_product_class": "1",
    "id_product_group": "1",
    "name_product_group": "میوه تازه",
    "product_figure": [
        {
            "id_product_figure": "1",
            "name_product_figure": "پرتقال_والنسا شمال"
        },
        {
            "id_product_figure": "2",
            "name_product_figure": "پرتقال_والنسا جنوب"
        },
        {
            "id_product_figure": "3",
            "name_product_figure": " پرتقال_تامسون ناول"
        },
        {
            "id_product_figure": "4",
            "name_product_figure": "پرتقال_خونی"
        },
        {
            "id_product_figure": "5",
            "name_product_figure": "نارنگی_انشیو شمال"
        },
        {
            "id_product_figure": "6",
            "name_product_figure": "نارنگی_کینو"
        },
        {
            "id_product_figure": "7",
            "name_product_figure": "نارنگی_یافا"
        },
        {
            "id_product_figure": "8",
            "name_product_figure": "نارنگی_تانجلو"
        },
        {
            "id_product_figure": "9",
            "name_product_figure": "نارنگی_پیج"
        },
        {
            "id_product_figure": "10",
            "name_product_figure": "لیموشیرین_جهرم"
        },
        {
            "id_product_figure": "11",
            "name_product_figure": "لیموشیرین_شمال"
        },
        {
            "id_product_figure": "12",
            "name_product_figure": "لیموشیرین_خوزستان"
        },
        {
            "id_product_figure": "13",
            "name_product_figure": "لیموترش_شیرازی"
        },
        {
            "id_product_figure": "14",
            "name_product_figure": "لیموترش_میناب"
        },
        {
            "id_product_figure": "15",
            "name_product_figure": "نارنج_شیرازی"
        },
        {
            "id_product_figure": "16",
            "name_product_figure": "گریپ فروت_جیرفتی"
        },
        {
            "id_product_figure": "17",
            "name_product_figure": "گریپ فروت_شیرازی"
        },
        {
            "id_product_figure": "18",
            "name_product_figure": "گریپ فروت_دزفولی"
        },
        {
            "id_product_figure": "19",
            "name_product_figure": "سیب_ردذلیشس"
        },
        {
            "id_product_figure": "20",
            "name_product_figure": "سیب_شکی"
        },
        {
            "id_product_figure": "21",
            "name_product_figure": "سیب_گلدن"
        },
        {
            "id_product_figure": "22",
            "name_product_figure": "سیب_گلاب"
        },
        {
            "id_product_figure": "23",
            "name_product_figure": "کیوی_هایوارد"
        },
        {
            "id_product_figure": "24",
            "name_product_figure": "کیوی_خونی"
        },
        {
            "id_product_figure": "25",
            "name_product_figure": "انار_غقدا"
        },
        {
            "id_product_figure": "26",
            "name_product_figure": "انار_رباب"
        },
        {
            "id_product_figure": "27",
            "name_product_figure": "انار_ملس"
        },
        {
            "id_product_figure": "28",
            "name_product_figure": "انار_دان سیاه"
        },
        {
            "id_product_figure": "29",
            "name_product_figure": "انگور_شاهانی"
        },
        {
            "id_product_figure": "30",
            "name_product_figure": "انگور_عسگری"
        },
        {
            "id_product_figure": "31",
            "name_product_figure": "انگور_شیرازی"
        },
        {
            "id_product_figure": "32",
            "name_product_figure": "انگور_صاحبی"
        },
        {
            "id_product_figure": "33",
            "name_product_figure": "انگور_شاهرودی"
        },
        {
            "id_product_figure": "34",
            "name_product_figure": "به_اصفهان"
        },
        {
            "id_product_figure": "35",
            "name_product_figure": "به_قرمز"
        },
        {
            "id_product_figure": "36",
            "name_product_figure": "خرمالو_فویو"
        },
        {
            "id_product_figure": "37",
            "name_product_figure": "شلیل"
        },
        {
            "id_product_figure": "38",
            "name_product_figure": "آلو"
        },
        {
            "id_product_figure": "39",
            "name_product_figure": "گیلاس"
        },
        {
            "id_product_figure": "40",
            "name_product_figure": "آلبالو"
        },
        {
            "id_product_figure": "41",
            "name_product_figure": "زردآلو"
        },
        {
            "id_product_figure": "42",
            "name_product_figure": "گلابی"
        },
        {
            "id_product_figure": "43",
            "name_product_figure": "هلو"
        },
        {
            "id_product_figure": "44",
            "name_product_figure": "انجیر"
        }
    ]
},
{
    "id_product_class": "1",
    "id_product_group": "2",
    "name_product_group": "میوه فریز",
    "product_figure": [
        {
            "id_product_figure": "1",
            "name_product_figure": "پرتقال_والنسا شمال"
        },
        {
            "id_product_figure": "2",
            "name_product_figure": "پرتقال_والنسا جنوب"
        },
        {
            "id_product_figure": "3",
            "name_product_figure": " پرتقال_تامسون ناول"
        },
        {
            "id_product_figure": "4",
            "name_product_figure": "پرتقال_خونی"
        },
        {
            "id_product_figure": "5",
            "name_product_figure": "نارنگی_انشیو شمال"
        },
        {
            "id_product_figure": "6",
            "name_product_figure": "نارنگی_کینو"
        },
        {
            "id_product_figure": "7",
            "name_product_figure": "نارنگی_یافا"
        },
        {
            "id_product_figure": "8",
            "name_product_figure": "نارنگی_تانجلو"
        },
        {
            "id_product_figure": "9",
            "name_product_figure": "نارنگی_پیج"
        },
        {
            "id_product_figure": "10",
            "name_product_figure": "لیموشیرین_جهرم"
        },
        {
            "id_product_figure": "11",
            "name_product_figure": "لیموشیرین_شمال"
        },
        {
            "id_product_figure": "12",
            "name_product_figure": "لیموشیرین_خوزستان"
        },
        {
            "id_product_figure": "13",
            "name_product_figure": "لیموترش_شیرازی"
        },
        {
            "id_product_figure": "14",
            "name_product_figure": "لیموترش_میناب"
        },
        {
            "id_product_figure": "15",
            "name_product_figure": "نارنج_شیرازی"
        },
        {
            "id_product_figure": "16",
            "name_product_figure": "گریپ فروت_جیرفتی"
        },
        {
            "id_product_figure": "17",
            "name_product_figure": "گریپ فروت_شیرازی"
        },
        {
            "id_product_figure": "18",
            "name_product_figure": "گریپ فروت_دزفولی"
        },
        {
            "id_product_figure": "19",
            "name_product_figure": "سیب_ردذلیشس"
        },
        {
            "id_product_figure": "20",
            "name_product_figure": "سیب_شکی"
        },
        {
            "id_product_figure": "21",
            "name_product_figure": "سیب_گلدن"
        },
        {
            "id_product_figure": "22",
            "name_product_figure": "سیب_گلاب"
        },
        {
            "id_product_figure": "23",
            "name_product_figure": "کیوی_هایوارد"
        },
        {
            "id_product_figure": "24",
            "name_product_figure": "کیوی_خونی"
        },
        {
            "id_product_figure": "25",
            "name_product_figure": "انار_غقدا"
        },
        {
            "id_product_figure": "26",
            "name_product_figure": "انار_رباب"
        },
        {
            "id_product_figure": "27",
            "name_product_figure": "انار_ملس"
        },
        {
            "id_product_figure": "28",
            "name_product_figure": "انار_دان سیاه"
        },
        {
            "id_product_figure": "29",
            "name_product_figure": "انگور_شاهانی"
        },
        {
            "id_product_figure": "30",
            "name_product_figure": "انگور_عسگری"
        },
        {
            "id_product_figure": "31",
            "name_product_figure": "انگور_شیرازی"
        },
        {
            "id_product_figure": "32",
            "name_product_figure": "انگور_صاحبی"
        },
        {
            "id_product_figure": "33",
            "name_product_figure": "انگور_شاهرودی"
        },
        {
            "id_product_figure": "34",
            "name_product_figure": "به_اصفهان"
        },
        {
            "id_product_figure": "35",
            "name_product_figure": "به_قرمز"
        },
        {
            "id_product_figure": "36",
            "name_product_figure": "خرمالو_فویو"
        },
        {
            "id_product_figure": "37",
            "name_product_figure": "شلیل"
        },
        {
            "id_product_figure": "38",
            "name_product_figure": "آلو"
        },
        {
            "id_product_figure": "39",
            "name_product_figure": "گیلاس"
        },
        {
            "id_product_figure": "40",
            "name_product_figure": "آلبالو"
        },
        {
            "id_product_figure": "41",
            "name_product_figure": "زردآلو"
        },
        {
            "id_product_figure": "42",
            "name_product_figure": "گلابی"
        },
        {
            "id_product_figure": "43",
            "name_product_figure": "هلو"
        },
        {
            "id_product_figure": "44",
            "name_product_figure": "انجیر"
        }
    ]
},
{
    "id_product_class": "2",
    "id_product_group": "3",
    "name_product_group": "صیفیجات میوه ای تازه",
    "product_figure": [
        {
            "id_product_figure": "50",
            "name_product_figure": "فلفل"
        },
        {
            "id_product_figure": "51",
            "name_product_figure": "خیار"
        },
        {
            "id_product_figure": "52",
            "name_product_figure": "گوجه"
        },
        {
            "id_product_figure": "53",
            "name_product_figure": "بادمجان"
        },
        {
            "id_product_figure": "54",
            "name_product_figure": "پیاز"
        },
        {
            "id_product_figure": "55",
            "name_product_figure": "سبیزمینی"
        },
        {
            "id_product_figure": "56",
            "name_product_figure": "هندونه"
        },
        {
            "id_product_figure": "57",
            "name_product_figure": "سیر"
        },
        {
            "id_product_figure": "58",
            "name_product_figure": "ملون"
        },
        {
            "id_product_figure": "59",
            "name_product_figure": "خربزه"
        },
        {
            "id_product_figure": "60",
            "name_product_figure": "هویج"
        },
        {
            "id_product_figure": "61",
            "name_product_figure": "بلال"
        }
    ]
},
{
    "id_product_class": "2",
    "id_product_group": "4",
    "name_product_group": "صیفیجات میوه ای فریز",
    "product_figure": [
        {
            "id_product_figure": "50",
            "name_product_figure": "فلفل"
        },
        {
            "id_product_figure": "51",
            "name_product_figure": "خیار"
        },
        {
            "id_product_figure": "52",
            "name_product_figure": "گوجه"
        },
        {
            "id_product_figure": "53",
            "name_product_figure": "بادمجان"
        },
        {
            "id_product_figure": "54",
            "name_product_figure": "پیاز"
        },
        {
            "id_product_figure": "55",
            "name_product_figure": "سبیزمینی"
        },
        {
            "id_product_figure": "56",
            "name_product_figure": "هندونه"
        },
        {
            "id_product_figure": "57",
            "name_product_figure": "سیر"
        },
        {
            "id_product_figure": "58",
            "name_product_figure": "ملون"
        },
        {
            "id_product_figure": "59",
            "name_product_figure": "خربزه"
        },
        {
            "id_product_figure": "60",
            "name_product_figure": "هویج"
        },
        {
            "id_product_figure": "61",
            "name_product_figure": "بلال"
        }
    ]
},
{
    "id_product_class": "3",
    "id_product_group": "5",
    "name_product_group": "صیفیجات برگی تاز",
    "product_figure": [
        {
            "id_product_figure": "62",
            "name_product_figure": "کلم"
        },
        {
            "id_product_figure": "63",
            "name_product_figure": "کاهو"
        },
        {
            "id_product_figure": "64",
            "name_product_figure": "کرفس"
        },
        {
            "id_product_figure": "65",
            "name_product_figure": "اسفناج"
        },
        {
            "id_product_figure": "66",
            "name_product_figure": "شوید"
        },
        {
            "id_product_figure": "67",
            "name_product_figure": "تره"
        },
        {
            "id_product_figure": "68",
            "name_product_figure": "نعنا"
        },
        {
            "id_product_figure": "69",
            "name_product_figure": "ترخون"
        }
    ]
},
{
    "id_product_class": "3",
    "id_product_group": "6",
    "name_product_group": "صیفیجات برگی فریز",
    "product_figure": [
        {
            "id_product_figure": "62",
            "name_product_figure": "کلم"
        },
        {
            "id_product_figure": "63",
            "name_product_figure": "کاهو"
        },
        {
            "id_product_figure": "64",
            "name_product_figure": "کرفس"
        },
        {
            "id_product_figure": "65",
            "name_product_figure": "اسفناج"
        },
        {
            "id_product_figure": "66",
            "name_product_figure": "شوید"
        },
        {
            "id_product_figure": "67",
            "name_product_figure": "تره"
        },
        {
            "id_product_figure": "68",
            "name_product_figure": "نعنا"
        },
        {
            "id_product_figure": "69",
            "name_product_figure": "ترخون"
        }
    ]
},
{
    "id_product_class": "4",
    "id_product_group": "7",
    "name_product_group": "مغزدانه ها",
    "product_figure": [
        {
            "id_product_figure": "70",
            "name_product_figure": "پسته"
        },
        {
            "id_product_figure": "71",
            "name_product_figure": "بادوم"
        },
        {
            "id_product_figure": "72",
            "name_product_figure": "فندق"
        },
        {
            "id_product_figure": "73",
            "name_product_figure": "بادام زمینی"
        },
        {
            "id_product_figure": "74",
            "name_product_figure": "کشمش"
        },
        {
            "id_product_figure": "75",
            "name_product_figure": "نخودچی"
        },
        {
            "id_product_figure": "76",
            "name_product_figure": "تخمه"
        },
        {
            "id_product_figure": "77",
            "name_product_figure": "گردو"
        }
    ]
},
{
    "id_product_class": "4",
    "id_product_group": "8",
    "name_product_group": "میوه خشک",
    "product_figure": [
        {
            "id_product_figure": "55",
            "name_product_figure": "سبیزمینی"
        }
    ]
},
{
    "id_product_class": "4",
    "id_product_group": "9",
    "name_product_group": " صیفیجات میوه ای خشک",
    "product_figure": [
        {
            "id_product_figure": "50",
            "name_product_figure": "فلفل"
        },
        {
            "id_product_figure": "51",
            "name_product_figure": "خیار"
        },
        {
            "id_product_figure": "52",
            "name_product_figure": "گوجه"
        },
        {
            "id_product_figure": "53",
            "name_product_figure": "بادمجان"
        },
        {
            "id_product_figure": "54",
            "name_product_figure": "پیاز"
        },
        {
            "id_product_figure": "56",
            "name_product_figure": "هندونه"
        },
        {
            "id_product_figure": "57",
            "name_product_figure": "سیر"
        },
        {
            "id_product_figure": "58",
            "name_product_figure": "ملون"
        },
        {
            "id_product_figure": "59",
            "name_product_figure": "خربزه"
        },
        {
            "id_product_figure": "60",
            "name_product_figure": "هویج"
        },
        {
            "id_product_figure": "61",
            "name_product_figure": "بلال"
        }
    ]
},
{
    "id_product_class": "4",
    "id_product_group": "10",
    "name_product_group": " صیفیجات برگی خشک",
    "product_figure": [
        {
            "id_product_figure": "62",
            "name_product_figure": "کلم"
        },
        {
            "id_product_figure": "63",
            "name_product_figure": "کاهو"
        },
        {
            "id_product_figure": "64",
            "name_product_figure": "کرفس"
        },
        {
            "id_product_figure": "65",
            "name_product_figure": "اسفناج"
        },
        {
            "id_product_figure": "66",
            "name_product_figure": "شوید"
        },
        {
            "id_product_figure": "67",
            "name_product_figure": "تره"
        },
        {
            "id_product_figure": "68",
            "name_product_figure": "نعنا"
        },
        {
            "id_product_figure": "69",
            "name_product_figure": "ترخون"
        }
    ]
},
{
    "id_product_class": "5",
    "id_product_group": "11",
    "name_product_group": "خرما مرطوب",
    "product_figure": [
        {
            "id_product_figure": "99",
            "name_product_figure": "کلیته"
        },
        {
            "id_product_figure": "100",
            "name_product_figure": "کبکاب"
        }
    ]
},
{
    "id_product_class": "5",
    "id_product_group": "12",
    "name_product_group": "خرما نیمه مرطوب",
    "product_figure": [
        {
            "id_product_figure": "101",
            "name_product_figure": "مضافتی"
        },
        {
            "id_product_figure": "102",
            "name_product_figure": "استعمران"
        }
    ]
},
{
    "id_product_class": "5",
    "id_product_group": "13",
    "name_product_group": "خرمای خشک",
    "product_figure": [
        {
            "id_product_figure": "103",
            "name_product_figure": "پیارم"
        },
        {
            "id_product_figure": "104",
            "name_product_figure": "ربی"
        },
        {
            "id_product_figure": "105",
            "name_product_figure": "ماجول"
        },
        {
            "id_product_figure": "106",
            "name_product_figure": "اجوه"
        },
        {
            "id_product_figure": "107",
            "name_product_figure": "سوکری"
        },
        {
            "id_product_figure": "108",
            "name_product_figure": "زاهدی"
        }
    ]
},
{
    "id_product_class": "5",
    "id_product_group": "14",
    "name_product_group": "رطب و خارک",
    "product_figure": [
        {
            "id_product_figure": "109",
            "name_product_figure": "رطب و خارک"
        }
    ]
},
{
    "id_product_class": "6",
    "id_product_group": "15",
    "name_product_group": "ادویه جات معطر",
    "product_figure": [
        {
            "id_product_figure": "78",
            "name_product_figure": "گشنیز"
        },
        {
            "id_product_figure": "79",
            "name_product_figure": "زیره"
        },
        {
            "id_product_figure": "97",
            "name_product_figure": "شاتره"
        },
        {
            "id_product_figure": "98",
            "name_product_figure": "اسپند"
        }
    ]
},
{
    "id_product_class": "6",
    "id_product_group": "16",
    "name_product_group": "گیاهان دارویی",
    "product_figure": [
        {
            "id_product_figure": "80",
            "name_product_figure": "گل محمدی"
        },
        {
            "id_product_figure": "81",
            "name_product_figure": "گل نسترن"
        },
        {
            "id_product_figure": "82",
            "name_product_figure": "مریم گلی"
        },
        {
            "id_product_figure": "83",
            "name_product_figure": "سرخارگل"
        },
        {
            "id_product_figure": "84",
            "name_product_figure": "آویشن"
        },
        {
            "id_product_figure": "85",
            "name_product_figure": "آنغوزه"
        },
        {
            "id_product_figure": "86",
            "name_product_figure": "زعفران"
        },
        {
            "id_product_figure": "87",
            "name_product_figure": "اسطخودوس"
        },
        {
            "id_product_figure": "88",
            "name_product_figure": "سماق"
        },
        {
            "id_product_figure": "89",
            "name_product_figure": "چای ترش"
        },
        {
            "id_product_figure": "90",
            "name_product_figure": "مورینگا"
        },
        {
            "id_product_figure": "91",
            "name_product_figure": "گل گاوزبان"
        },
        {
            "id_product_figure": "92",
            "name_product_figure": "بیدمشک"
        },
        {
            "id_product_figure": "93",
            "name_product_figure": "خارمریم"
        },
        {
            "id_product_figure": "94",
            "name_product_figure": "بنفشه"
        },
        {
            "id_product_figure": "95",
            "name_product_figure": "حنا"
        },
        {
            "id_product_figure": "96",
            "name_product_figure": "پنیرک"
        }
    ]
}

]

相关问题