json

JSON Normalize with Value as Column

JSON Normalize with Value as Column Question: I have the following JSON; { "data": [ { "gid": "1203715497540179", "completed": false, "custom_fields": [ { "gid": "1203887422469746", "enabled": true, "name": "Inputs", "description": "", "display_value": null, "resource_subtype": "text", "resource_type": "custom_field", "text_value": null, "type": "text" }, { "gid": "1126427465960522", "enabled": false, "name": "T-Minus", "description": "", "display_value": "54", "resource_subtype": "text", …

Total answers: 1

Obtaining information from a list/dict in Python

Obtaining information from a list/dict in Python Question: I understand this question may have been asked in many different formats in the past. I also checked the recommended answers when I wrote the question title, and I haven’t found what I need. I’m new to Python so my understanding of lists and dictionaries is slowly …

Total answers: 2

Python nested dictionary – remove "" and data with extra spaces but keep None values

Python nested dictionary – remove "" and data with extra spaces but keep None values Question: I have a dictionary and would like to keep None values but remove values with "" and also values of any combination of " "’s I have the following dictionary: {‘UserName’: ”, ‘Location’: [{‘City’: ”, ‘Country’: ‘Japan’, ‘Address 1’: …

Total answers: 2

json.decoder.JSONDecodeError: Invalid control character when we try to parse a JSON

json.decoder.JSONDecodeError: Invalid control character when we try to parse a JSON Question: json.decoder.JSONDecodeError: Invalid control character error when i try to parse a JSON string. import json import pprint json_data = None with open("C:\Users\75\OneDrive\PROJECT P1\Work_1.0\CBP\server.txt", ‘r’) as f: data = f.read() json_data = json.loads(data) pprint.pprint(json_data) f.close() jsonString = json.dumps(json_data,default = str) jsonFile = open("converted.json", "w") …

Total answers: 1

Problem installing a Python program from GitHub

Problem installing a Python program from GitHub Question: I am trying to install the MQTT simulator. I have python v3.3.10 installed in my computer. I followed this video between 1:48 and 5.43, so now I have a folder in my desktop called python_project, inside of which there is a folder called venv. I have downloaded …

Total answers: 1

FastAPI unit test returns 422

FastAPI unit test returns 422 Question: I am new to python and FastAPI and writing some test code for FastAPI endpoints. I have the following function for unit testing, but when I run it I get back status code 422. Not sure what I am doing wrong: def test_create_event(self): my_date = datetime.date(2023, 6, 15) data …

Total answers: 1

Django ORM & Django REST Framework: How to make "grouped" arrays?

Django ORM & Django REST Framework: How to make "grouped" arrays? Question: Currently, my Django server can return the JSON below: [ { "id": 1, "customer": { "id": 1, "name": "John Doe" }, "description1": "…", "description2": "…", "description3": "…", "description4": "…" }, { "id": 2, "customer": { "id": 1, "name": "John Doe" }, "description1": "…", …

Total answers: 2

Getting the newest line added to a json and sending in discord.py

Getting the newest line added to a json and sending in discord.py Question: I am making a discord bot using discord.py and have a nice little setup so when I add something to my json file it checks every 20 seconds and if something has changed then it will send a discord embed with the …

Total answers: 2

replace characters in a json file

replace characters in a json file Question: I’ve done some wrong manipulation of a 100 json files. Not sure what happened, but most of my json files now have a random number of the last characters repeated (as per image below). Is there a way to clean a json file by deleting characters starting from …

Total answers: 1