Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
vibur
Apr 23, 2004
I'm pulling data from a REST API into objects so I have a bunch of Property: Value pairs.

For example:
code:
name                  : iPad
udid                  : a long udid
Mobile Device Group   :
id                    : 663
Display_Name          : iPad
Asset_Tag             : A5035
Last_Inventory_Update : 2023-07-01 22:59:23
Serial_Number         : XXXXXXXXXX
Battery_Level         : 50
I need to push those into a Google Sheet for data viz purposes. Google's API wants JSON but it just wants the values (because each set of values is another row). What I can't figure out is how to get just the values from the object when I don't know the property names ahead of time. I feel like this should be pretty basic object manipulation but I just can't put my finger on it. Anyone know how to do that offhand?

Adbot
ADBOT LOVES YOU

vibur
Apr 23, 2004

nielsm posted:

I'm not sure I understand, do you mean like an array of arrays?

code:
[
  ["iPad", "a long udid", "", 663, "iPad", "A5035", "2023-07-01 22:59:23", "XXXXXXXXXX", 50],
  ["iPad 2", "another udid", "", 842, "iPad 2", "A5035", "2023-07-01 22:59:25", "XXXXXXXXXX", 98]
]
Like that, with no header information?

Since I assume you've already tried ConvertTo-Json directly on your data and decided that it will not work.
This is exactly correct. Google's API takes each of those arrays as a row in the spreadsheet.

Also, *I* didn't decide ConvertTo-Json will not work, Google took care of that for me :(

vibur fucked around with this message at 21:36 on Jul 5, 2023

vibur
Apr 23, 2004
FWIW, I appear to have solved my own problem (sort of).

Falling down a search hole, I saw a post from someone using ChatGPT to solve a different problem so I gave it a shot. It came up with some unfamiliar cmdlets that led me to PSGSuite.

My testing so far has been good - appends object values to a sheet with no need to convert to an arraylist or JSON or whatever.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply