It took me a while to fully wrap my head around it, but in the end the arduinojson library does the trick for me: