How to create a JSON with unknown number of fields