json

How to normalize a list from a json file using python?

How to normalize a list from a json file using python? Question: I have a sample file like this sample.json { "school":[ { "testId":123, "testName":"test1", "Teachers":[ { "Tid":111, "Tname":"aaa" }, { "Tid":222, "Tname":"bbb" }, { "Tid":333, "Tname":"ccc" }, { "Tid":444, "Tname":"ddd" } ], "location":"India" } ] } i need to normalize the Teachers list from …

Total answers: 1

How can I locate where in a JSON file a key is located?

How can I locate where in a JSON file a key is located? Question: I’m writing a parser that uses a JSON file for configuration, and if it detects an invalid value, I want to be able to output the location of the problematic data in the form of the line and column number in …

Total answers: 1

UnicodeDecodeError for a Python script to extract URLs from a batch of JSON files

UnicodeDecodeError for a Python script to extract URLs from a batch of JSON files Question: I’m trying to make a script for extracting URLs from a batch of JSON files but I’m getting this error I can’t figure out how to resolve: UnicodeDecodeError: ‘charmap’ codec can’t decode byte 0x98 in position 7837: character maps to …

Total answers: 1

How to get values of the choosen keys in a nested json

How to get values of the choosen keys in a nested json Question: I have a json that looks like this dict = { "a1": { "b1" : 1 , "b2" ; { "c1" : 24, "c2" : 25}, "b3" : { "c3" : 45, "c4" : 1, "c5" : 4} }, "a2" : 4} …

Total answers: 2

Normalize a nested json file in Python

Normalize a nested json file in Python Question: Suppose a list of objects: one, two, three,… Every object is composed of name, foo1, and foo2 fields. [{ ‘name’:’one’, ‘foo2’:{ ‘id’:’1.1′, ‘id’:’1.2′ }, ‘foo1’:[ { ‘foo2’:{ ‘id’:’1.1′, ‘name’:’one.one’ } }, { ‘foo2’:{ ‘id’:’1.2′, ‘name’:’one.two’ } } ] }] If the object is normalize using: obj_row_normalize = …

Total answers: 1

Python, JSON How can I check if the time selected by the user is not already booked by someone else?

Python, JSON How can I check if the time selected by the user is not already booked by someone else? Question: I have 2 CSV and JSON files: name, start_time, end_time Michał Najman, 23.03.2023 14:00, 23.03.2023 15:00 Marcin Wiśniewski, 23.03.2023 17:00, 23.03.2023 18:00 Tadeusz Stockinger, 24.03.2023 11:00, 24.03.2023 12:30 Robert Brzozowski, 24.03.2023 12:30, 24.03.2023 14:00 …

Total answers: 1

Loop through a string-list and make key:pair in json format in Python

Loop through a string-list and make key:pair in json format in Python Question: I have a csv file as: devid,1, devType,"type-928" devid,2, devType,"type-930" etc. Length of the lines might be different, depending on the number of key-pair values included. But must have ‘devid’ and ‘devType’ in them. Want to pair them as key:value and format …

Total answers: 2

How to filtering out json object contain certain key in FLASK?

How to filtering out json object contain certain key in FLASK? Question: I have a JSON file : { "id":"xyz", "word":"this is word", "formats":[ { "formatId":"xz99", "pengeluaran":"pengeluaran_1", }, { "formatId":"xy100", "pengeluaran":"pengeluaran_2", }, { "ukuran":451563, "formatId":"xy101", "pengeluaran":"pengeluaran_1", }, } in my python.py files, i want to filtering out the JSON object only contain "ukuran" as a …

Total answers: 1

Send StringSet to DynamoDB from JSON file using Boto3

Send StringSet to DynamoDB from JSON file using Boto3 Question: Problem description How can I create an item to send to DynamoDB from a JSON file, and have the type in DynamoDB end up as a StringSet as defined in AWS documentation using Python? I am using the Boto3 put_item API. Approaches attempted I’ve found …

Total answers: 2

Error: Object of type IntervalStrategy is not JSON serializable when add `indent` to verticalize json

Error: Object of type IntervalStrategy is not JSON serializable when add `indent` to verticalize json Question: I want to save a dataclass to a json file and save it, it is ok now without adding paramenter indent. class EnhancedJSONEncoder(json.JSONEncoder): def default(self, o): if dataclasses.is_dataclass(o): return dataclasses.asdict(o) # return super().default(o) model_json = json.dumps(model_args, cls=EnhancedJSONEncoder) model_args is …

Total answers: 2