Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validate JSON file
#3
Thanks for the reply, but now getting the error for the "return json.load(f)" line of code.

This is what i changed the code to

import json
 
def parse(text):
    try:
        with open("C:\python-script\file\assetLink_tr-TR.json") as f:
        return json.load(f)
    except ValueError as e:
        print('invalid json: %s' % e)
        return None # or: raise
This is the new error
File "C:\python-script\JSON_Validate.py", line 6
return json.load(f)
^
IndentationError: expected an indented block

if the indentation is still wrong, can you please indent the 9 lines so i see where i am going wrong.

Once again, thanks for your help
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 389 Mar-28-2024, 05:16 PM
Last Post: deanhystad
  parse json field from csv file lebossejames 4 880 Nov-14-2023, 11:34 PM
Last Post: snippsat
  Python Script to convert Json to CSV file chvsnarayana 8 2,724 Apr-26-2023, 10:31 PM
Last Post: DeaD_EyE
  Loop through json file and reset values [SOLVED] AlphaInc 2 2,357 Apr-06-2023, 11:15 AM
Last Post: AlphaInc
  Converting a json file to a dataframe with rows and columns eyavuz21 13 5,108 Jan-29-2023, 03:59 PM
Last Post: eyavuz21
  validate large json file with millions of records in batches herobpv 3 1,375 Dec-10-2022, 10:36 PM
Last Post: bowlofred
  Create SQL connection function and validate mg24 1 1,025 Sep-30-2022, 07:45 PM
Last Post: deanhystad
Sad how to validate user input from database johnconar 3 2,097 Sep-11-2022, 12:36 PM
Last Post: ndc85430
  Writing to json file ebolisa 1 1,082 Jul-17-2022, 04:51 PM
Last Post: deanhystad
  Trying to parse only 3 key values from json file cubangt 8 3,695 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