0

How to get meta-data describing the returned JSON data below and load it into an object?

**********************
Transcript started, output file is jsonfu
PS /home/nicholas/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e> $request = 'http://musicbrainz.org/ws/2/recording/fcbcdc39-8851-4efc-a02a-ab0e13be224f?inc=artist-credits+isrcs+releases&fmt=json'
PS /home/nicholas/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e> $result = Invoke-WebRequest $request
PS /home/nicholas/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e> $result

StatusCode        : 200
StatusDescription : OK
Content           : {"releases":[{"id":"9c7a7669-b43a-3323-906b-c3f0bedc10c9","release-events":[{"date":"2007-11-07","area":{"type"
                    :null,"name":"Japan","disambiguation":"","iso-3166-1-codes":["JP"],"type-id":null,"sort-n…
RawContent        : HTTP/1.1 200 OK
                    Date: Thu, 17 Dec 2020 14:48:49 GMT
                    Connection: keep-alive
                    Keep-Alive: timeout=15
                    Vary: Accept-Encoding
                    X-RateLimit-Limit: 1200
                    X-RateLimit-Remaining: 749
                    X-RateLimit-Reset: 1608216530…
Headers           : {[Date, System.String[]], [Connection, System.String[]], [Keep-Alive, System.String[]], [Vary,
                    System.String[]]…}
Images            : {}
InputFields       : {}
Links             : {}
RawContentLength  : 4732
RelationLink      : {}


PS /home/nicholas/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e> exit
**********************
PowerShell transcript end
End time: 20201217064923
**********************

this is in the context of parsing a JSON file stored locally.

This is on Linux, so not quite sure what might not be available.

see also:

Iterating through a JSON file PowerShell

which looks, if not intractable, then at least not insignificant.

  • 2
    In this specific example, if you use `Invoke-RestMethod` instead, PowerShell should do a decent job of converting the output to an object for you. This can then in turn be examined with `Get-Member`. If you have a stored JSON file (which, I should add, the transcript you have above is *not*, it's just a transcript with all sorts of other stuff mixed in and parsing it takes more effort) you can use `ConvertFrom-Json` to convert the JSON explicitly, then use `Get-Member`. – Jeroen Mostert Dec 17 '20 at 15:00

1 Answers1

0

thanks Jeroen mostert:

**********************
Transcript started, output file is jsonfu2
PS /home/nicholas/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e> $url = 'http://musicbrainz.org/ws/2/recording/fcbcdc39-8851-4efc-a02a-ab0e13be224f?inc=artist-credits+isrcs+releases&fmt=json'
PS /home/nicholas/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e> $response=Invoke-RestMethod -Url $url
PS /home/nicholas/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e> TerminatingError(Invoke-RestMethod): "A parameter cannot be found that matches parameter name 'Url'."

Invoke-RestMethod: A parameter cannot be found that matches parameter name 'Url'.

Invoke-RestMethod: A parameter cannot be found that matches parameter name 'Url'.
PS /home/nicholas/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e> $response=Invoke-RestMethod
PS /home/nicholas/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e> $response

releases       : {@{packaging=; title=LAST ANGEL; status=Official; id=9c7a7669-b43a-3323-906b-c3f0bedc10c9;
                 artist-credit=System.Object[]; date=2007-11-07; text-representation=;
                 status-id=4e304316-386d-3409-af2e-78857eec5cfe; packaging-id=; release-events=System.Object[];
                 barcode=4988064457663; quality=normal; country=JP; disambiguation=}, @{title=Kingdom; status=Official;
                 packaging=; id=56b1246a-7ff4-4183-b2f6-4e3f6cfacd05; date=2008-01-30; text-representation=;
                 artist-credit=System.Object[]; packaging-id=; status-id=4e304316-386d-3409-af2e-78857eec5cfe; quality=normal;
                 release-events=System.Object[]; barcode=; country=JP; disambiguation=}, @{packaging-id=;
                 status-id=4e304316-386d-3409-af2e-78857eec5cfe; date=2008-01-30; text-representation=;
                 artist-credit=System.Object[]; id=149aabbf-a54c-4156-a83b-47e0e1ab1069; status=Official; title=Kingdom;
                 packaging=; disambiguation=; country=JP; quality=normal; release-events=System.Object[]; barcode=}, @{country=KR;
                 disambiguation=; quality=normal; barcode=8809049753128; release-events=System.Object[]; text-representation=;
                 date=2008-01-31; artist-credit=System.Object[]; packaging-id=; status-id=4e304316-386d-3409-af2e-78857eec5cfe;
                 status=Official; title=Kingdom; packaging=; id=abcd76db-7d5f-3eb7-b386-051c97bfe2e4}…}
disambiguation : video
title          : LAST ANGEL
length         :
isrcs          : {}
id             : fcbcdc39-8851-4efc-a02a-ab0e13be224f
artist-credit  : {@{name=倖田來未; artist=; joinphrase= feat. }, @{artist=; name=東方神起; joinphrase=}}
video          : True


PS /home/nicholas/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e> $response | Get-Member

   TypeName: System.Management.Automation.PSCustomObject

Name           MemberType   Definition
----           ----------   ----------
Equals         Method       bool Equals(System.Object obj)
GetHashCode    Method       int GetHashCode()
GetType        Method       type GetType()
ToString       Method       string ToString()
artist-credit  NoteProperty Object[] artist-credit=System.Object[]
disambiguation NoteProperty string disambiguation=video
id             NoteProperty string id=fcbcdc39-8851-4efc-a02a-ab0e13be224f
isrcs          NoteProperty Object[] isrcs=System.Object[]
length         NoteProperty object length=null
releases       NoteProperty Object[] releases=System.Object[]
title          NoteProperty string title=LAST ANGEL
video          NoteProperty bool video=True

PS /home/nicholas/Desktop/takeout-20201215T221239Z-001/Takeout/Hangouts Chat/Groups/e> exit
**********************
PowerShell transcript end
End time: 20201217071644
**********************

although I'm not sure that fully describes the JSON.