早在PowerShell 3.0的时候就被引入了两个新的cmdlet命令,一个是ConvertFrom-Json 和ConvertTo-Json ,虽然目前看来过了很久,因为最近有需要处理到Json的数据,既然PowerShell已经支持Json数据了,因此,我觉得可以拿PowerShell对Json做些数据处理。就以这两个命令作为例子开始吧。
先说说ConvertTo-Json这个命令,从字面我们可以看出来它应该是一个把对象转换为一种Json格式的命令,一起来看一下帮助文档简介:
Detailed Description
The ConvertTo-Json cmdlet converts any object to a string in JavaScript Object Notation (JSON) format. The properties are converted to field names, the field values are converted to property values, and the methods are removed.
You can then use the ConvertFrom-Json cmdlet to convert a JSON-formatted string to a JSON object, which is easily managed in Windows PowerShell.
Many web sites use JSON instead of XML to serialize data for communication between servers and web-based apps.
我们可以从简介中