@@ -350,15 +350,15 @@ const jsonResponseBodyText = computed(() => {
350350 () =>
351351 JSONPath ({
352352 path: filterQueryText .value ,
353- json: parsedJSON as any ,
353+ json: JSON . parse ( LJSON . stringify ( parsedJSON as any ) || " {} " ) ,
354354 }),
355355 (err ): BodyParseError => ({
356356 type: " JSON_PATH_QUERY_FAILED" ,
357357 error: err as Error ,
358358 })
359359 )
360360 ),
361- E .map (JSON . stringify )
361+ E .map (( result : any ) => result as string | object )
362362 )
363363 }
364364 return E .right (responseBodyText .value )
@@ -369,12 +369,35 @@ const jsonBodyText = computed(() => {
369369 props .response as HoppRESTResponse
370370 )
371371
372- return pipe (
372+ const rawValue = pipe (
373373 jsonResponseBodyText .value ,
374- E .getOrElse (() => responseBodyText .value ),
374+ E .getOrElse (() => responseBodyText .value )
375+ )
376+
377+ // If the rawValue is already an object (from JSONPath filtering), stringify it directly
378+ if (typeof rawValue === " object" && rawValue !== null ) {
379+ return JSON .stringify (rawValue , null , 2 )
380+ }
381+
382+ // If it's a string, we need to parse and re-stringify
383+ const stringValue = rawValue as string
384+
385+ // If we're filtering, the string should already be clean JSON (no lossless numbers)
386+ if (filterQueryText .value .length > 0 ) {
387+ return pipe (
388+ stringValue ,
389+ O .tryCatchK (JSON .parse ),
390+ O .map ((val ) => JSON .stringify (val , null , 2 )),
391+ O .getOrElse (() => stringValue )
392+ )
393+ }
394+
395+ // For unfiltered responses, use LJSON for lossless parsing
396+ return pipe (
397+ stringValue ,
375398 O .tryCatchK (LJSON .parse ),
376399 O .map ((val ) => LJSON .stringify (val , undefined , 2 )),
377- O .getOrElse (() => responseBodyText . value )
400+ O .getOrElse (() => stringValue )
378401 )
379402})
380403
@@ -401,13 +424,19 @@ const filterResponseError = computed(() =>
401424 }
402425 }
403426 },
404- (result ) =>
405- result === " []"
427+ (result ) => {
428+ const isEmpty =
429+ typeof result === " object" && result !== null
430+ ? Array .isArray (result ) && result .length === 0
431+ : result === " []"
432+
433+ return isEmpty
406434 ? {
407435 type: " RESPONSE_EMPTY" ,
408436 error: t (" error.no_results_found" ).toString (),
409437 }
410438 : undefined
439+ }
411440 )
412441 )
413442)
0 commit comments