Question: I'm pretty new to PS and been struggling for a few days.
I have multiple text files in a folder with specific data that I would like to extract into an excel spreadsheet.
each files look like this :

```
Client n° : xxx Client name : xxx

                Computer status

pc group 1 : 

n°1 OK                   n°2 Disconnected               n°3 Unresponsive
n°4 Unreachable host     n°5 Unresponsive

Data read 11/11/20 12:50:07

Version: x.x.x 

```

I would like to have an output file that looks like this :

```
 Client name and n°     OK       Disconnected      Unresponsive    Unreachable host   version       
     xxx/xxx            1             1                2                 1             x.x.x

```

For the status columns it's the sum number of pc with that status and not the pc n° that I would like to display.

At the moment I'm working with multiple .bat files that searches for the status and output one file per status

```
find /c "Disconnected" *.* > disconnected.txt
find /c "Unresponsive" *.* > unresponsive.txt

```

And then I sort every single output in an excel which takes me too much time, I was wondering if it was possible to automate this task with a script.

I really don't have any knowledge of PS, only basic batch commands.

Answer: 
As `body.data.attributes.municipalities` is a array, we can't put it `"municipalities":` directly. For your requirement of modify the format of the json data, we need to write every property of each array item. Below is my steps for your reference.

My json is:

```
{
    "data": {
        "attributes": {
            "municipalities": [
                {
                    "name": "hury",
                    "email": "hury@mail.com"
                },
                {
                    "name": "mike",
                    "email": "mike@email.com"
                }
            ]
        }
    }
}

```

And my liquid template show as:
[![enter image description here](https://i.stack.imgur.com/eKTYV.png)](https://i.stack.imgur.com/eKTYV.png)

==============================**Update**============================

First the code `JObject inBody = context.Request.Body.As<JObject>();` you shared can't get the response data. You should use `JObject inBody = context.Response.Body.As<JObject>();`.

Then for your question about "Is there an easier way to remove `.attributes` part, I provide a solution below for your reference.

Do not use liquid template, use `Replace` to replace `"attributes": {` with empty and use `Substring` to remove the last `}`.

```
<set-body>@{ 
    JObject inBody = context.Response.Body.As<JObject>();
    string str = inBody.ToString();
    string str1 = str.Replace("\"attributes\": {", "");
    string result = str1.Substring(0, str1.Length-1);
    return result; 
}</set-body>

```

**Notice: This approach requires a high degree of specification for your response data format.**
I also managed to get the desired output with the below code, so that the code is generic and doesnt need to do any string operations.

```
<set-body>@{ 
    JToken inBody = context.Response.Body.As<JToken>()["data"]["attributes"];
    JObject jsonObject = new JObject{
    ["data"] = inBody
}; 
return jsonObject.ToString();
}</set-body>

```