[PR #4916] [MERGED] feat: format JSON responses having text/plain content type #4987

Closed
opened 2026-03-17 02:28:39 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/4916
Author: @anwarulislam
Created: 3/19/2025
Status: Merged
Merged: 3/28/2025
Merged by: @jamesgeorge007

Base: nextHead: feat/json-for-text-plain


📝 Commits (2)

  • 21367fb feat: add JSON validation for text/plain responses
  • 51e7396 chore: keep JSON lens reserved for valid response body

📊 Changes

2 files changed (+37 additions, -2 deletions)

View changed files

📝 packages/hoppscotch-common/src/helpers/lenses/jsonLens.ts (+26 -1)
📝 packages/hoppscotch-common/src/helpers/lenses/lenses.ts (+11 -1)

📄 Description

Closes HFE-791 #4239

This pull request introduces improvements to the JSON lens functionality in the hoppscotch-common package. The key changes include adding a utility function to validate JSON strings, updating the JSON lens to handle text/plain content types, and modifying the lens selection logic to prioritize the JSON lens for valid JSON content.

Enhancements to JSON lens functionality:

What's changed

  • Not Completed
  • Completed

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/4916 **Author:** [@anwarulislam](https://github.com/anwarulislam) **Created:** 3/19/2025 **Status:** ✅ Merged **Merged:** 3/28/2025 **Merged by:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Base:** `next` ← **Head:** `feat/json-for-text-plain` --- ### 📝 Commits (2) - [`21367fb`](https://github.com/hoppscotch/hoppscotch/commit/21367fb809cf30b3f9835096b1be382a5ebd3739) feat: add JSON validation for text/plain responses - [`51e7396`](https://github.com/hoppscotch/hoppscotch/commit/51e7396f951d22473e7c5449a50bf068b23f45c3) chore: keep JSON lens reserved for valid response body ### 📊 Changes **2 files changed** (+37 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/src/helpers/lenses/jsonLens.ts` (+26 -1) 📝 `packages/hoppscotch-common/src/helpers/lenses/lenses.ts` (+11 -1) </details> ### 📄 Description Closes HFE-791 #4239 This pull request introduces improvements to the JSON lens functionality in the `hoppscotch-common` package. The key changes include adding a utility function to validate JSON strings, updating the JSON lens to handle `text/plain` content types, and modifying the lens selection logic to prioritize the JSON lens for valid JSON content. ### Enhancements to JSON lens functionality: * [`packages/hoppscotch-common/src/helpers/lenses/jsonLens.ts`](diffhunk://#diff-cbd2b0f64781739021c5b10c958805700cf8a1c12211b3c7d840e2f6570297ffL2-R29): Added a new function `isValidJSONResponse` to check if a string can be parsed as valid JSON. * [`packages/hoppscotch-common/src/helpers/lenses/lenses.ts`](diffhunk://#diff-79bfbf40575328139052e5ff8d6c432b3345dec7dcf6f01e0f0f5db5abecaa1fL2-R2): Imported the new `isValidJSONResponse` function. ### What's changed * [`packages/hoppscotch-common/src/helpers/lenses/lenses.ts`](diffhunk://#diff-79bfbf40575328139052e5ff8d6c432b3345dec7dcf6f01e0f0f5db5abecaa1fR48-R57): Modified the `getSuitableLenses` function to consider the JSON lens if the content type is `text/plain` and the response body contains valid JSON. - [ ] Not Completed - [x] Completed --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:28:39 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#4987
No description provided.