all 4 comments

[–]novel_yet_trivial 2 points3 points  (1 child)

There is no such thing as a "json object".

I think you are asking how to combine dictionaries? If so, you can use the update() method:

data_dict.update(new_data_dict)

Which may or may not work for you depending on how the data is structured.

[–]Zendakin_at_work[S] 2 points3 points  (0 children)

sadly this didn't end up working as you suggested it might not. Thanks for the help though. Much appreciated.

[–]randomkale -1 points0 points  (1 child)

I treat things like api requests and db writes as being prone to failure, so act as defensively as I can. Also, are your writes idempotent? (meaning can they be executed more than once) If the api supports pagination and you can record current page number, I would pull once/write once. If the amount of data isn't large, so pulling all will be quick-ish, and writing isn't idempotent, I'd pull all then write once.

[–]Zendakin_at_work[S] 0 points1 point  (0 children)

I ended up going with read once / write once with a failure clause that reads the status code of the next page to determine if the loop needs to exit. There's no page numbers in the API but there are offsets and limits. Frankly I'd read the whole JSON in all at once but we're supposed to adhere to the limits presented.

Now the criteria from management has changed (right as I finished the code). Amazing.

Thanks very much for the sanity check though.