Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you put JSON into environment variables?

I have a Google Analytics API JSON Key (a json file containing credential information). It should be stored as environment variables. How do you do that? I think I have two options.

  1. Encode JSON in Base64 and store it as single key:value environment variable pair.
  2. List all key and value pairs into environment variables. Thanks!
like image 764
Watanabe.N Avatar asked Sep 15 '25 04:09

Watanabe.N


1 Answers

You can store entire JSON objects in your .env file as long as you properly handle the double quotes.

  • Escape the double quotes with a backslash (\")
  • Wrap the JSON object with single quotes
like image 83
Joe Muller Avatar answered Sep 17 '25 20:09

Joe Muller