2

I'm working on generating json schema documents based on json documents we import from our vendors and partners.The below code works fine. But, now as I'm working on building on it to create a module where it would take input parameters for the path of the json document and the path where json schema would be saved on to Azure data lake gen2 storage.

Python:

import json
from genson import SchemaBuilder

jsondoc = 'C:\\json\\test.json'
jsonschema = 'C:\\schema\\test.schema.json'

builder = SchemaBuilder()
with open(jsondoc, 'r', encoding="utf-8") as f:
    datastore = json.load(f)
    builder.add_object(datastore )

builder.to_schema()
#print(builder.to_json(indent=2))

with open(jsonschema, 'w') as outfile:
    print(builder.to_json(indent=2),file=outfile)

Now I would like to pass the jsondoc and jsonschema as parameters and the path would be Azure data lake gen2. This python code would be run in Azure automation.

paone
  • 828
  • 8
  • 18

0 Answers0