Format JSON to one line per input

314 views Asked by At

I'm trying to make my json compatible with Google ML, which after some searching means having one line per input instance (Input instances are not in JSON format.)

How can I change my code to have only one line per instance? (img variable is the image I encoded to base64)

json.dumps({"inputs": {"b64": img}})
1

There are 1 answers

0
Teodor Ivanov On BEST ANSWER

The format you're referring to is called json-lines (.jl for a file extension).
You can use the json-lines python package in place of json.dumps.