C#C
C#5mo ago
VoidPointer

Recursive, or Nested, JSON Parsing

I'm trying to design a viewer for JSON downloads of GCP log entries, and an example of the start of an entry looks like the image. You see, with my explanation, that the
textPayload
and
label.session
properties contain "nested" JSON, which is escaped, and these JSON strings sometimes contain further "nested" JSON objects.

I would like a viewer that can show e.g.
textPayload
as a collapsed node of a tree, at the same level as its peer properties, like
insertId
,
timestamp
, and
severity
, which will cannot be collapsed or expanded. Then anothed collapsed node for
labels
, and under it another collapsed node for
session
.

Then if I expand say the
textPayload
node, it displays that nested JSON object as a normal tree under
textPayload
. The shape of this nested object is not fixed, so manually deserializing it if a user clicks its
+
icon is difficult.

I would prefer to somehow dynamically deserialize the whole log entry at once, using some sort of JsonNode or JsonObject classes in a tree structure instead of deserializing into a hierarchy of static, known, object types. I only really need the next of each JSON property node in the log entry, I don't need to work with any defined C# types for these nodes.
image.png
Was this page helpful?