-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Property support for Dumping Newtonsoft.Json and System.Text.Json objects #14
Comments
I can try out a few things on how to render json. But I can look around a bit, and see if I can figure it out. |
I have tried a few things with Generating JSON, and so far the easiest would be to consider JValue (NewtonSoft) and JsonValue (System.Text.Json) as KnownSingleValues, and then generating them using the SingleValueDescriptor. Alternatively, I can add a separate Descripter + Render-method for the Json-Values, which would hopefully make it easier to customize in the future. For the following JSON-input, we will then get the follwowing output: [
{
"Sample":"Basic Sample",
"Id": 1,
"Text":"StringValue"
},
{
"Sample": "Object Sample",
"Id": 2,
"Nested Object": {
"Bool": false,
"Text": "StringValue"
}
},
{
"Sample":"Array Sample",
"Id": 3,
"Array": [1,2,3]
}
] |
Great work @Hejle, thanks! |
Why not render them as json instead of table? Spectre.Console already support it. Doc here |
Description
@Hejle has pointed out that our current support for dumping
Newtonsoft.Json
andSystem.Text.Json
objects are lacking.Examples/reproduction:
Suggested solution:
We can either use
DumpConfig.Default.AddCustomTypeHandler(typeof(JValue), (obj, _, _, _) => obj.ToString());
or we can create a custom type renderer for Json objects.I think we should compile a list of objects of both
Newtonsoft.Json
andSystem.Text.Json
that we would have to custom render and decide how to render each one of them.We may start with a simple solution, which is using
AddCustomTypeHandler
until we implement a proper custom renderer.The text was updated successfully, but these errors were encountered: