JSON code into liquid on the fly while page load

As per our app requirement. I want to put some JSON code into liquid on the fly while page load. without using ajax. what will be best approach to achieve this

Use liquid to print the JSON code into js