Skip to content
Advertisement

Tag: json

Python code to multiple JSON files with different names

I’m new to python and programming in general, asking for help: What to run in python code to print this data in multiple JSON files (300 files) that every file change the “name” line from #1 to #300 and the JSON files names will be like from 1.json to 300.json is it possible? Answer try this:

check if JSON response has an object

I’m trying to filter out if a JSON response has objects, and do something if it has. My Problem is that even if it has objects, it won’t trigger the break. Here is my code: Answer print(email.get_list_of_emails()) return None. This is why you never get the break. Try to remove the print Try to change the code to something like

Nested python dataclasses with list annotations

python ^3.7. Trying to create nested dataclasses to work with complex json response. I managed to do that with creating dataclass for every level of json and using __post_init_ to set fields as objects of other dataclasses. However that creates a lot of boilerplate code and also, there is no annotation for nested objects. This answer helped me getting closer

Filter null values from JSON

I receive the following JSON from the MS Graph API: How can I filter the null values using Python (3.9) ? Answer First of all, processing it is easier when it’s been converted to python data structure, such as a dict. The built-in json module can convert a json-string into python objects using json.loads. You can create a new dictionary

Issue with Base64 encoding in Python and Decoding in Java

I have two packages running, one is written in python and the other in Java. The python package encodes a json(dictionary) object and sends it to the java package which decodes it into a specific POJO. Let the json in python be: { “name”: “John”, “Age”: 24, “Income”: None } The problem is that Java does not support None, it

Extract three values from JSON output

I am trying to get three specific values from within a JSON return. I can only figure out how to get ALL the information rather than specific pieces. Here’s the JSON output (note – the date 2021-08-13:2 is going to change every week but I need that value also the 710.0 will likely change, too): What I need is the

Advertisement