jeudi 20 août 2015

generating unique ids for a list of JSON objects, when more objects may need to be added later

I have a JSON file which contains around 1,000,000 entries. I want to create a unique identifier for each entry in the JSON file.

The catch is, somewhere down the line I may have to add more entries into the JSON file, and those will need unique identifiers as well.

What would be the best way to approach writing a script that could delegate all these entries a unique identifier?

Solutions I have thought of include using uuid in python to generate random ids, but that would only work once and I would have to redo the whole file each time I add any new objects. Or, I could just number all the objects sequentially, but that doesn't seem like a great/extensible solution, as there is no inherent ordering to my data.




Aucun commentaire:

Enregistrer un commentaire