Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validate JSON file
#11
exactly, there is just a function definition, you never call it. also, the text argument is not used. better, something within these lines:

import json
    
def parse(fname):
    try:
        with open(fname) as f:
            return json.load(f)
    except ValueError as e:
        print('invalid json: %s' % e)
        return None
file_name = r"C:\python-script\file\assetLink_tr-TR.json"
print(parse(file_name))
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Validate JSON file - by BellaMac - Feb-25-2020, 10:42 AM
RE: Validate JSON file - by johnb546 - Feb-25-2020, 10:53 AM
RE: Validate JSON file - by BellaMac - Feb-25-2020, 11:11 AM
RE: Validate JSON file - by DeaD_EyE - Feb-25-2020, 12:52 PM
RE: Validate JSON file - by BellaMac - Feb-25-2020, 01:44 PM
RE: Validate JSON file - by BellaMac - Feb-26-2020, 02:13 PM
RE: Validate JSON file - by DeaD_EyE - Feb-26-2020, 03:17 PM
RE: Validate JSON file - by BellaMac - Feb-26-2020, 05:46 PM
RE: Validate JSON file - by buran - Feb-26-2020, 05:49 PM
RE: Validate JSON file - by BellaMac - Feb-26-2020, 06:03 PM
RE: Validate JSON file - by buran - Feb-26-2020, 06:06 PM
RE: Validate JSON file - by BellaMac - Feb-27-2020, 08:41 AM
RE: Validate JSON file - by snippsat - Feb-27-2020, 03:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  encrypt data in json file help jacksfrustration 1 289 Mar-28-2024, 05:16 PM
Last Post: deanhystad
  parse json field from csv file lebossejames 4 804 Nov-14-2023, 11:34 PM
Last Post: snippsat
  Python Script to convert Json to CSV file chvsnarayana 8 2,612 Apr-26-2023, 10:31 PM
Last Post: DeaD_EyE
  Loop through json file and reset values [SOLVED] AlphaInc 2 2,219 Apr-06-2023, 11:15 AM
Last Post: AlphaInc
  Converting a json file to a dataframe with rows and columns eyavuz21 13 4,742 Jan-29-2023, 03:59 PM
Last Post: eyavuz21
  validate large json file with millions of records in batches herobpv 3 1,326 Dec-10-2022, 10:36 PM
Last Post: bowlofred
  Create SQL connection function and validate mg24 1 979 Sep-30-2022, 07:45 PM
Last Post: deanhystad
Sad how to validate user input from database johnconar 3 1,992 Sep-11-2022, 12:36 PM
Last Post: ndc85430
  Writing to json file ebolisa 1 1,048 Jul-17-2022, 04:51 PM
Last Post: deanhystad
  Trying to parse only 3 key values from json file cubangt 8 3,558 Jul-16-2022, 02:05 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020