skip to Main Content

How to add sub item to json in for loop

I am trying to achieve the following json output: My current code: #!/usr/bin/env python3.9 import json complete_lst = [] url_lst = ['https://', 'https://', 'https://'] complete_lst.append({'title': 'Hello'}) for url in url_lst: complete_lst.append({'watch': {'Season1': {'url': url}} }) with open("Hello.json", "w") as file:…

VIEW QUESTION

How to add object in laravel relationships

How to add extra object in laravel relationship when fatch data. Here is my code: $list = new self; $list = $list->where('uuid', $uuid); $list = $list->where('user_id', $user->id)->orWhere('to_user_id', $user->id); $list = $list->with(['touser' => function($q1) { $q1 = $q1->select('id', 'name', 'email', 'user_image',…

VIEW QUESTION

Json – Trying to iterate through a list of dictionaries

I have json list. I would like to iterate "PrivateIP" through a list of dirctories and append to the empty list: here's the code: InstanceId = [] message = [{"SNowTicket":"RITM00001","ServerIPList":[{"PrivateIP":"182.0.0.0", "HostName":"ip-182-0-0-0.ec2.internal", "Region":"us-east-1", "AccountID":"12345678"}, {"PrivateIP": "182.1.1.1", "HostName": "ip-182-1-1-1.ec2.internal", "Region": "us-east-1", "AccountID":…

VIEW QUESTION

Parsing a Nested JSON Object

I need to parse a JSON object recursively. Here is a sample JSON: const obj = { tag: 'AA', type: 'constructed', value: 'ABCD1', child: [ { tag: 'BB', type: 'constructed', value: 'ABCD2', child: [ { tag: 'CC', type: 'constructed', value:…

VIEW QUESTION

JSON_TABLE – Get nodes regardless of path

In a XML like this: <item> <id>1</id> <name>ITEM 1</name> <subitems> <item> <id>2</id> <name>SUBITEM 1</name> <subitems/> </item> <item> <id>3</id> <name>SUBITEM 2</name> <subitems> <item> <id>4</id> <name>SUBITEM 3</name> <subitems/> </item> </subitems> </item> </subitems> </item> There can be several levels of subitems in the…

VIEW QUESTION
Back To Top
Search