add tag
PeterVandivier
I've got some [mongoexport] output I'd like to quickly parse. As you know, this output is pseudo-json in style. Mine looks like this:

```json
{"_id":{"$oid":"efd3"},"docs":{"77c2":{"a":1},"5031":{"a":2}}}
{"_id":{"$oid":"5a6e"},"docs":{"5d4c":{"a":3},"9d1b":{"a":4}}}
{"_id":{"$oid":"e659"},"docs":{"b932":{"a":5},"2250":{"a":6}}}
```

I'm pretty sure the object `b932` exists in there somewhere, and since each line is a discrete json document, I'll [grep] for it and pipe the output into [ConvertFrom-Json]. 

![Screenshot 2020-06-12 at 12.42.26.png](/image?hash=49f3d9effa2c15a7037a64a44e18021513bf6482c59e96e80e71d2e342dc8c0e)

Easy peasy, I can see in the object level preview that the grep colorisation was preserved in the pipeline. That's fun and unexpected I guess, but I do have `export GREP_OPTIONS='--color=always'` in my `.bash_profile` which was the environment I was in before `pwsh`, so fair enough, I guess it got inherited ¯\\\_(ツ)_/¯

Anyway... let's see what the data for `b932` is...

![Screenshot 2020-06-12 at 12.48.57.png](/image?hash=8ddd132d078a4a08c1d0527273f3469f22d716a3beadf8127679a62e5d5a40ae)

...huh? What's going on, the docs are here, right...?

![Screenshot 2020-06-12 at 12.49.32.png](/image?hash=7d625c7063286d7a89049bb5cc2bc8d9abf9af37e550163380ea072086738b01)

...yes...?

Anyway, it turns out you cannot index into document `b392` in any of the "usual" ways here

```powershell
$object.docs.b932
$object.docs.'b932'
$object.docs['b932']
```

Additionally [Get-Member] shows some... interesting output here too. 

![Screenshot 2020-06-12 at 12.53.34.png](/image?hash=1b515808676b28ed9fdbf25d0191ba994fcd196646fff5f06c56169e835c485b)

So... _what's going on!?_

[mongoexport]: https://docs.mongodb.com/manual/reference/program/mongoexport/
[grep]: https://ss64.com/osx/grep.html
[ConvertFrom-Json]: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/convertfrom-json
[Get-Member]: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/Get-Member
Top Answer
PeterVandivier
As a workaround, use `--color=none` to strip the colour from the left side of your pipeline before converting the object.

```powershell
[3.61ms] /Users/pvandivier/Desktop
PS> $object = grep b932 ./foo.dump --color=none | ConvertFrom-Json
[40.4ms] /Users/pvandivier/Desktop
PS> $object.docs.b932

a
-
5

[3.45ms] /Users/pvandivier/Desktop
PS>
```

This room is for discussion about this question.

Once logged in you can direct comments to any contributor here.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.