Powershell: How to Update/Replace data and values in Json and XML Object

Viewed 23425

So I am having a bit of a problem here, I can't seem to figure out how to update data values in an Object

so lets say for example the FOLLOWING json

{
    "People": 263,
    "Hungry": true,
    "Fruits": {
        "Apples": 1 "Oranges": 2
    },
    "Places": {
        "Places": [{
                "Baskets": "true",
                "name": "Room 1",
                "candycount": 1500,
                "candytypespresent": {
                    "candies": [
                        "caramel"
                    ]
                }

            },
            {

                "Baskets": "false",
                "name": "Room 2",
                "candycount": 2000,
                "candytypespresent": {
                    "candies": [
                        "caramel",
                        "jawbreaker",
                        "butterscotch"
                    ]
                }
            }
        ]
    }
}

I have Powershell read it smoothly with convertfrom-json

How would I do the following:

A) Change "Oranges" from "2" to "100"

B) "Baskets" in Room 2 from "false" to "true"

C) add "bubblegum" to "candies" in Room1

HOW can I update this without rewriting the WHOLE json or object?

1 Answers
Related