json_validate_test.py 618 B

12345678910111213141516171819202122
  1. #!/usr/bin/env python
  2. #
  3. # SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
  4. # SPDX-License-Identifier: Apache-2.0
  5. #
  6. import json
  7. import os
  8. from sys import stdin
  9. try:
  10. import jsonschema
  11. except ImportError:
  12. raise RuntimeError('You need to install jsonschema package to use validate command')
  13. input_json = ''
  14. for line in stdin:
  15. input_json += line
  16. size_json = json.loads(input_json)
  17. with open(os.path.join(os.path.dirname(__file__), 'size_schema.json'), 'r') as schema_file:
  18. schema_json = json.load(schema_file)
  19. jsonschema.validate(size_json, schema_json)
  20. print(input_json.strip('\n'))