I am trying to import/read the data from a file which is in array of hash table (key, value) but unable to do because the default assign sign (=) is not used instead colon (:) is used. I have tried different ways to read the data but powershell throws me an error every time. the data (truncated here) is in below format (notice the equal sign is replaced with :
[{"name":"Alex","IQ":"A+"},{"name":"Steve","IQ":"60"},{"name":"Lisa","IQ":"90"},{"name":"Jackie","IQ":"B"}]
How can I read this data into array or variable, so I can work with it? This is the error message:
> @a = [{"name":"Alex","IQ":"A+"},{"name":"Steve","IQ":"60"},{"name":"Lisa","IQ":"90"},{"name":"Jackie","IQ":"B"}]
At line:1 char:7
+ @a = [{"name":"Alex","IQ":"A+"},{"name":"Steve","IQ":"60"},{"name":"L ...
+ ~
Missing type name after '['.
At line:1 char:14
+ @a = [{"name":"Alex","IQ":"A+"},{"name":"Steve","IQ":"60"},{"name":"L ...
+ ~~~~~~~
Unexpected token ':"Alex"' in expression or statement.
At line:1 char:21
+ @a = [{"name":"Alex","IQ":"A+"},{"name":"Steve","IQ":"60"},{"name":"L ...
+ ~
Missing argument in parameter list.
At line:1 char:40
+ @a = [{"name":"Alex","IQ":"A+"},{"name":"Steve","IQ":"60"},{"name":"L ...
+ ~~~~~~~~
Unexpected token ':"Steve"' in expression or statement.
At line:1 char:48
+ @a = [{"name":"Alex","IQ":"A+"},{"name":"Steve","IQ":"60"},{"name":"L ...
+ ~
Missing argument in parameter list.
At line:1 char:67
+ ... ":"Alex","IQ":"A+"},{"name":"Steve","IQ":"60"},{"name":"Lisa","IQ":"9 ...
+ ~~~~~~~
Unexpected token ':"Lisa"' in expression or statement.
At line:1 char:74
+ ... :"Alex","IQ":"A+"},{"name":"Steve","IQ":"60"},{"name":"Lisa","IQ":"90 ...
+ ~
Missing argument in parameter list.
At line:1 char:93
+ ... "Steve","IQ":"60"},{"name":"Lisa","IQ":"90"},{"name":"Jackie","IQ":"B ...
+ ~~~~~~~~~
Unexpected token ':"Jackie"' in expression or statement.
At line:1 char:102
+ ... Steve","IQ":"60"},{"name":"Lisa","IQ":"90"},{"name":"Jackie","IQ":"B" ...
+ ~
Missing argument in parameter list.
At line:1 char:1
+ @a = [{"name":"Alex","IQ":"A+"},{"name":"Steve","IQ":"60"},{"name":"L ...
+ ~~
The splatting operator '@' cannot be used to reference variables in an expression. '@a' can be used only as an
argument to a command. To reference variables in an expression use '$a'.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingTypename