charmbracelet / lipgloss

Style definitions for nice terminal layouts 👄
MIT License
8.24k stars 231 forks source link

Render table to JSON #335

Closed decentral1se closed 2 months ago

decentral1se commented 4 months ago

Is your feature request related to a problem? Please describe.

I want to render my lipgloss.Table as JSON.

Describe the solution you'd like

Guessing at an API surface: lipgloss.Table.ToJSON()

Describe alternatives you've considered

Gather results separately from the lipgloss.Table and render myself. There is currently no way to get the raw data you put into lipgloss.Table via Header/Row(s) back out again. So you need to do additional bookkeeping to render stuff later on.

Additional context

A sub-request is probably an API surface to retrieve the data that you put in without additional bookkeeping (e.g. GetHeaders()) 🙃 In the case you don't want to implement a full JSON rendering API surface.

bashbunni commented 2 months ago

Hey, I'm not sure about having this kind of behaviour handled by Lip Gloss itself. What do you think about having it handled by a helper library instead? Lip Gloss Convert is a great example of this.

I'm going to move this to a discussion to keep the conversation open!