Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

powershell convert to json

You could try some string manipulation to get it in an expected JSON format, and then use ConvertFrom-Json to convert it to a PSCustomObject.

Simple Example: (simple because this assumes that these characters being replaced will only be delimiters)

# First, clean up the string.
PS C:> $mystring = "@{Account='User01';Domain='Domain01';Admin='True'}"
PS C:> $mystring = $mystring -replace "^@", ""
PS C:> $mystring = $mystring -replace "=", ":"
PS C:> $mystring = $mystring -replace ";", ","
PS C:> $mystring
{Account:'User01',Domain:'Domain01',Admin:'True'}

# Afterwards, convert to PSCustomObject.
PS C:> $myobject = $mystring | ConvertFrom-Json
PS C:> $myobject

Account                                 Domain                                  Admin
-------                                 ------                                  -----
User01                                  Domain01                                True
Comment

how to convert back to JSON in powershell

ConvertTo-Json -InputObject $my_object
Comment

PREVIOUS NEXT
Code Example
Shell :: Flatpak in linux 
Shell :: push docker image to docker hub 
Shell :: bash remove trailing whitespace from every line 
Shell :: git config --global http.sslverify "false" This command resolve my problem 
Shell :: postinstall docker 
Shell :: git clone depth 
Shell :: how to put files into gitignore 
Shell :: git switch 
Shell :: read from .env file bash 
Shell :: force remove hidden folder in linux 
Shell :: create repository, commit, and push 
Shell :: nvm install 
Shell :: linux groups 
Shell :: how to remove git from ubuntu 21 
Shell :: how to check whats using my space linux 
Shell :: sl in linux 
Shell :: ubuntu locate binary file 
Shell :: install apexcharts 
Shell :: how to disable browser autofill in Autocomplete mui component 
Shell :: ffmpeg add audio to image 
Shell :: install screen recorder linux 
Shell :: npm install -g express 
Shell :: rails all path 
Shell :: get bluetooth devices powershell 
Shell :: copy from remote server 
Shell :: ubuntu start sublime 3 
Shell :: install astropy anaconda 
Shell :: open folder from terminal ubuntu 
Shell :: git update .gitignore 
Shell :: download terraform for mac 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =