- 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?
|
#
¿
Jul 5, 2023 21:01
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
Apr 29, 2024 07:21
|
|
- vibur
- Apr 23, 2004
-
|
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
|
#
¿
Jul 5, 2023 21:30
|
|
- 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.
|
#
¿
Jul 7, 2023 21:21
|
|