A way to create JSON file for cmdstanpy in python?

I’ve recently started learning cmdstanpy(or stan in general), and was wondering if there is a way to create a JSON data file other than manually converting data using json.dump in python.

So for example, say I have six columns, each with different length, I’ve manually converted each column into a JSON file using json.dump in python, then in RStudio, combine all those data by copy and pasting.

1 Like

Welcome to Discourse!

Does jsondump in cmdstanpy.utils help you? Or since your goal is to get these into R, perhaps rdump (also in cmdstanpy.utils) might help.

3 Likes

Wow thank you so much.

thank u!!! worked in my case also
work time

this has been renamed to write_stan_json (as in CmdStanR) and is now properly documented and will be in the next CmdStanPy release. Expose write_stan_json utility by WardBrian · Pull Request #418 · stan-dev/cmdstanpy · GitHub

2 Likes