json-to-env

command module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 1 Imported by: 0

README

Download

Download from the Releases

OR

go install github.com/hxhieu/json-to-env@latest

Usage

Convert the JSON format to .env format

Usage:
  json-to-env [flags]

Flags:
  -h, --help               help for json-to-env
  -o, --output string      The output file (default ".env")
  -s, --separator string   The nested fields separator (default "__")

Example

// appsettings.json

{
  "Logging": {
    "LogLevel": {
      "Default": "Debug",
      "Microsoft": "Information",
      "System": "Information",
      "Microsoft.EntityFrameworkCore.Database.Command": "Warning"
    },
    "UseDeveloperExceptionPage": "true"
  }
}

Output as

# .env

Logging__LogLevel__Default: "Debug"
Logging__LogLevel__Microsoft: "Information"
Logging__LogLevel__System: "Information"
Logging__LogLevel__Microsoft.EntityFrameworkCore.Database.Command: "Warning"
Logging__UseDeveloperExceptionPage: "true"

Known issues

  • JSON fields ordering are not preserved
  • JSON comments // and /* */ are not supported so remove them in prior
  • : as separator will cause weird output

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL