{"id":86304,"date":"2019-09-04T15:00:08","date_gmt":"2019-09-04T23:00:08","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/scripting\/?p=86304"},"modified":"2019-09-01T13:43:32","modified_gmt":"2019-09-01T21:43:32","slug":"powertip-read-a-json-configuration-file-as-a-powershell-object","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-read-a-json-configuration-file-as-a-powershell-object\/","title":{"rendered":"PowerTip: Read a JSON configuration file as a PowerShell object"},"content":{"rendered":"<p><strong>Summary<\/strong>: Using the ConvertFrom-Json Cmdlet in PowerShell to read a JSON formatted file<\/p>\n<p><img decoding=\"async\" width=\"34\" height=\"34\" class=\"wp-image-86305\" src=\"http:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/09\/a-picture-containing-scissors-description-automat.jpeg\" alt=\"A picture containing scissors\n\nDescription automatically generated\" \/><\/p>\n<p>Hey, Doctor Scripto! I&#8217;ve seen a lot of JSON files in use in Azure. I&#8217;m not very good with editing JSON properly. Is there an easy way to read this and at least edit it with PowerShell?<\/p>\n<p><img decoding=\"async\" width=\"34\" height=\"34\" class=\"wp-image-86306\" src=\"http:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/09\/word-image.jpeg\" \/><\/p>\n<p>Most definitely my good friend. For the file below called &#8220;settings.json&#8221; you can convert it to a PowerShell Object for editing purposes using the following line. \u00a0 Once you have completed this, you can manipulate it like any other PowerShell Object.<\/p>\n<p><strong>$PowerShellObject=Get-Content -Path settings.json | ConvertFrom-Json<\/strong><\/p>\n<p><img decoding=\"async\" width=\"96\" height=\"145\" class=\"wp-image-86307\" src=\"http:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/09\/word-image-5.png\" \/><\/p>\n<p>PowerShell, Doctor Scripto, Sean Kearney, PowerTip, JSON<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Using the ConvertFrom-Json Cmdlet in PowerShell to read a JSON formatted file Hey, Doctor Scripto! I&#8217;ve seen a lot of JSON files in use in Azure. I&#8217;m not very good with editing JSON properly. Is there an easy way to read this and at least edit it with PowerShell? Most definitely my good friend. [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1739,639],"tags":[1740,621,377,356,154],"class_list":["post-86304","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-doctor-scripto","category-powertip","tag-doctor-scripto","tag-json","tag-powershell","tag-powertip","tag-sean-kearney"],"acf":[],"blog_post_summary":"<p>Summary: Using the ConvertFrom-Json Cmdlet in PowerShell to read a JSON formatted file Hey, Doctor Scripto! I&#8217;ve seen a lot of JSON files in use in Azure. I&#8217;m not very good with editing JSON properly. Is there an easy way to read this and at least edit it with PowerShell? Most definitely my good friend. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/86304","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=86304"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/86304\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=86304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=86304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=86304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}