Skip to content
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

Beautify JSON and highlight json text #595

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Mrudul111
Copy link
Contributor

@Mrudul111 Mrudul111 commented Feb 22, 2025

PR Description

This PR was made to tackle 2 enhancement issues that are beautification of JSON text and highlight of key and string value in JSON text and plug it in body section of History Request page and Request page. Here is a video demonstrating the functionality.

Simulator.Screen.Recording.-.iPhone.SE.3rd.generation.-.2025-02-22.at.13.47.07.mp4

Related Issues

Checklist

  • I have gone through the contributing guide
  • I have updated my branch and synced it with project main branch before making this PR
  • I am using the latest Flutter stable branch (run flutter upgrade and verify)
  • I have run the tests (flutter test) and all tests are passing

Added/updated tests?

We encourage you to add relevant test cases.

  • Yes
  • No, and this is why: This enhancement feature does not need any tests

OS on which you have developed and tested the feature?

  • Windows
  • macOS
  • Linux

@ashitaprasad
Copy link
Member

The JSON theme does not match the light mode and dark mode theme we currently use in the app

If you go to "View Code" -> "HAR" (which is a JSON, you can see the highlighting)

Screenshot 2025-02-22 at 2 54 03 PM Screenshot 2025-02-22 at 2 53 51 PM

The current theme resides here -
https://github.com/foss42/apidash/blob/main/packages/apidash_design_system/lib/tokens/themes.dart

@Mrudul111
Copy link
Contributor Author

should I use the same color scheme as HAR or we should go for another color scheme.

@ashitaprasad
Copy link
Member

should I use the same color scheme as HAR or we should go for another color scheme.

All colour scheme flow through the API Dash design system as mentioned in the comment link above.
Your theme should be derived from the same color scheme.

@Mrudul111
Copy link
Contributor Author

should I use the same color scheme as HAR or we should go for another color scheme.

All colour scheme flow through the API Dash design system as mentioned in the comment link above. Your theme should be derived from the same color scheme.

I used the attr and string color from the same file. Is that good or should we go for another pair from the same file?
Simulator Screenshot - iPhone SE (3rd generation) - 2025-02-22 at 22 36 46
Simulator Screenshot - iPhone SE (3rd generation) - 2025-02-22 at 22 36 36

key: Key("${selectedHistoryModel?.historyId}-json-body"),
fieldKey:
"${selectedHistoryModel?.historyId}-json-body-viewer",
initialValue: requestModel?.body,
readOnly: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read only feature is important as the user cannot modify the JSON body when viewing history.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On it

@ashitaprasad
Copy link
Member

@Mrudul111 You forgot adding the following styles in the JSON editor:

numberHighlightStyle
boolHighlightStyle
nullHighlightStyle

@Mrudul111
Copy link
Contributor Author

@Mrudul111 You forgot adding the following styles in the JSON editor:

numberHighlightStyle
boolHighlightStyle
nullHighlightStyle

what should be the color for nullHighlightStyle the same as string?

@ashitaprasad
Copy link
Member

@Mrudul111 You forgot adding the following styles in the JSON editor:

numberHighlightStyle
boolHighlightStyle
nullHighlightStyle

what should be the color for nullHighlightStyle the same as string?

You have access to the theme and the code view widget. It is part of the task to figure out how the colors map.

@Mrudul111
Copy link
Contributor Author

This looks good to me. Every variable is uniquely identifiable
Simulator Screenshot - iPhone SE (3rd generation) - 2025-02-23 at 14 02 45
Simulator Screenshot - iPhone SE (3rd generation) - 2025-02-23 at 14 03 01

@ashitaprasad
Copy link
Member

What is your FOSSHACK project link?

@Mrudul111
Copy link
Contributor Author

project

I am not contributing to FOSSHACK

@ashitaprasad
Copy link
Member

project

I am not contributing to FOSSHACK

cool 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants