Share your repls and programming experiences

← Back to all posts
JSON Object to Env Converter
h
RohilPatel (1534)

I use firebase quite frequently, and I don't really enjoy putting my object into .env, even though I have to.

With this new project, which is more practicality than effort, you can convert any JSON object into .env compatible format.

If this post receives enough attention and you guys want it I could add error handling and stuff, and other features like arrays in json or what not.

Have a good day!

Comments
hotnewtop
BobTheTomatoPie (3357)

I mean this in no offense, but compared to your other projects this is kinda low effort, cause I mean you make awesome stuff, but this is like 29 lines that just rearange the text basically, and please don't take this offensively, i'm just saying you could do better than this

RohilPatel (1534)

Yeah, I explained this in my description above, however, I thought it was cool to share with people since it has a more practical use than any of my other projects. I don't need any cycles from this project, however giving people some tools to help them with such stuff is useful to them @BobTheTomatoPie

RohilPatel (1534)

Yeah, I'm not too worried about cycles or anything, I just wanted to make a useful tool, it's better people use it than have to struggle or waste time making their own @BobTheTomatoPie

zplusfour (890)

its awesome
btw, can you replace whitespaces with underscore?
because you can't store environment variables with whitespaces:

RohilPatel (1534)

Yeah sure, I'll get to work on that one @zplusfour

RohilPatel (1534)

Done! It was pretty easy! @zplusfour

zplusfour (890)

@RohilPatel

well you made it just to replace the first whitespace not all the whitespaces...
invite me

RohilPatel (1534)

Nah, no need to invite. I think I fixed it for real this time. I forgot that .replace() makes it only for the first instance of it. I fixed it with .split().join() @zplusfour

ch1ck3n (1618)

You know, people always give up when the first result of google search isn't very good, but there's about 500 good projects on repl.it that they can use

RohilPatel (1534)

@ch1ck3n there are, and I'm glad you found it useful!

Spotandjake (27)

Firebase is designed so you do not need to hide your token lol. not to mention you do not need to hide the entire config i suggest you take a look at.

there are many more of these for the different services all along the same line the security rule language is very similar to js and rather easy to understand. hope this helps.

Spotandjake (27)

@Spotandjake alternativly you could just store it like

CONFIG="{}"

and JSON.parse and JSON.strigify the key would be a lot smarter as json configs that are deeper than one level would not work with a system like what you have.

RohilPatel (1534)

This is true, however if you guys get my token and stuff, you could write to my database which is something you don't want to happen. @Spotandjake

RohilPatel (1534)

Regarding the one level, yes you are right, however, with my firebase keys, it only has one layer @Spotandjake

Spotandjake (27)

@RohilPatel that is not true at all if you use the correct security rules then you cant and if you are using firebase you should take the time the idea behind it is controlled writes which is completly safe if you write the rules correctly.

Spotandjake (27)

@RohilPatel another thing is replit has changed the way envs work for explorers meaning no easy copy paste of many keys is all so it would make far more sense to do it that way. what you have helps people i am just recommmending improvoments to the design for future and general use. and also pointing out something about firebase that should really be used.

RohilPatel (1534)

Not if ur using firestore @Spotandjake

Spotandjake (27)

@RohilPatel yes if your using firestore lol the security rules are made to filter the ways the reads, writes deletes really any query can access yes it means they can write but only under certain circumstances and it is very much safe if you correctly write your security rules lol.

RayhanADev (1977)

Lmao, I was literally using Firebase like 5 seconds ago on my big project and I go from:

(╬ Ò﹏Ó)

to:

\(^ヮ^)/

awesome!

RohilPatel (1534)

Lol did u convert using this? @RayhanADev

RayhanADev (1977)

@RohilPatel after I saw this heck yes xD

RohilPatel (1534)

Haha, Im working on a bot that needs to store stuff, but I was held back since I didn't want to convert everything lol @RayhanADev

ch1ck3n (1618)

{"ch1ck3n": "awesome", "doge": "wow", "AAAA": "OOOOOOOO"}

Is equal to

ch1ck3n = "awesome"

doge = "wow"

AAAA = "OOOOOOOO"