Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9021127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:10:54+00:00 2026-06-16T05:10:54+00:00

I want to parse JSON in PowerShell but I can’t use the new v3

  • 0

I want to parse JSON in PowerShell but I can’t use the new v3 functions that are available in PowerShell. My first thought was to load the JSON.Net assembly and use that to parse the JSON string but it doesn’t work as I expect it to.

I have this JSON:

$json = "{""Name"": ""Apple"",  
           ""Price"": 3.99,  
            ""Sizes"": [    
                 ""Small"",    
                 ""Medium"",
                 ""Large""]}"

I load the JSON.NET assembly with this code:

[Reflection.Assembly]::LoadFile("$currentPath\Newtonsoft.Json.dll”)

And tries to parse it with

$result = [Newtonsoft.Json.JsonConvert]::DeserializeObject($json)

Now I expect that $result["Name"] is Apple but I get nothing there. Any ideas?

The code ´$result.ContainsKey(“Name”)returnsTruebut$result.GetValue(“Name”)returnsnull`.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:10:55+00:00Added an answer on June 16, 2026 at 5:10 am

    Ok, so here is how I did it so it works down to at least PowerShell v2 on Windows 2008.

    First, load the Json.NET assembly for the version you would like to use, I took the .NET 3.5 version:

    [Reflection.Assembly]::LoadFile("Newtonsoft.Json.dll")
    

    I had the JSON in a file since it was used in a deployment configuration I wrote, so I needed to read the file and then parse the json

    $json = (Get-Content $FileName | Out-String) # read file
    $config = [Newtonsoft.Json.Linq.JObject]::Parse($json) # parse string
    

    Now to get values from the config you need to to use the Item method which seems defined by PowerShell on hashtables/dictionaries. So to get an item that is a simple string you would write:

    Write-Host $config.Item("SomeStringKeyInJson").ToString()
    

    If you had an array of things you would need to do something like

    $config.Item("SomeKeyToAnArray") | ForEach-Object { Write-Host $_.Item("SomeKeyInArrayItem").ToString() }
    

    To access nested items you write

    $config.Item("SomeItem").Item("NestedItem")
    

    That’s how I solved parsing JSON with Json.NET in PowerShell.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use Gson to parse my JSON, I've added Gson library into
I want to parse my json by fromJson class but I am unable to
I am new to JSON.In my asp.net application i want to parse the json
I am working in C#. I want to parse JSON in my application. But
I want to parse json , but I didn't find how to parse array
I want to parse JSON arrays and using gson. Firstly, I can log JSON
i have an json array and i want to parse it in java-script but
this the JSON data that i want to parse in my application: { viewdeal:[
I am new in BB trying to parse Json file and just want to
I want to parse this Json code : [{id:7,key:integrationContinue:integrationContinue,name:life Portlet,scope:PRJ,qualifier:TRK,date:2012-03-26T10:10:22+0100,lname:life Portlet,lang:java,version:1.0-SNAPSHOT,description:,msr:[{key:ncloc,val:897.0,frmt_val:897},{key:coverage,val:0.6,frmt_val:0,6%}]}] I created two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.