File: validate-json.py

package info (click to toggle)
gcompris-qt 26.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 144,692 kB
  • sloc: javascript: 64,854; cpp: 7,375; xml: 1,349; python: 1,310; sh: 584; sql: 236; php: 183; java: 121; perl: 40; ansic: 14; makefile: 7; awk: 6
file content (25 lines) | stat: -rwxr-xr-x 556 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/python
#
# GCompris - validate-json.py
#
# SPDX-FileCopyrightText: 2015 Bruno Coudoin <bruno.coudoin@gcompris.net>
#
#   SPDX-License-Identifier: GPL-3.0-or-later
import json
import sys

if len(sys.argv) != 2:
    print("Usage: validate-json.py json_file")
    sys.exit(1)

inf=sys.argv[1]

with open(inf) as data_file:
    try:
        data = json.load(data_file)
        print("Processing OK " + inf)
    except ValueError as e:
        print(dir(e))
        print("Processing KO " + inf)
        print("Parser error: {0}".format(e.message))