Giter VIP home page Giter VIP logo

Comments (4)

Hejle avatar Hejle commented on August 27, 2024 1

I can try out a few things on how to render json.
One thing I have already noticed, is that it is considerably harder to work with System.Text.Json, as its JValue equiviliant "JsonValue" is created as a JsonValueTrimmable which I can't really get the typeof.

But I can look around a bit, and see if I can figure it out.

from dumpify.

Hejle avatar Hejle commented on August 27, 2024 1

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]
  }
]

billede

from dumpify.

MoaidHathot avatar MoaidHathot commented on August 27, 2024

Great work @Hejle, thanks!
I want to keep the descriptors as general as possible, so creating a new type of descriptor only for Json-types should be our last resort.
A better option IMO is to create a custom renderer and register all of the Json-related types in our custom type handlers. Currently I don't like that we need to do it in CustomValueGenerator. I would like to first work on a way to register the custom-types directly via the custom renderers, so we only have to specify types that need custom rendering in one place, which is the renderer itself.
Once that is done, it will be easier to write a single ICustomTypeRenderer that support the json-related types.

from dumpify.

latop2604 avatar latop2604 commented on August 27, 2024

Why not render them as json instead of table? Spectre.Console already support it. Doc here

image

from dumpify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.