C#C
C#3y ago
Alisa

✅ getting all the keys of a json object

The json input I have is:
{
  "vacuum": [],
  "dust": []
}

What I want as output is:
vacuum
dust

The json is contained in a JsonObject, and I'm trying to make a method to do what I'm talking about:
    public void List()
    {
        foreach (var key in jsonObj)
        {
            Console.WriteLine(key);
        }
    }

But the output I'm getting is:
[vacuum, []]
[dust, []]
Was this page helpful?