(text: string)
| 1 | import type { CallResult, JsonObject } from "./types" |
| 2 | |
| 3 | export function parse(text: string): unknown { |
| 4 | if (!text) return undefined |
| 5 | try { |
| 6 | return JSON.parse(text) as unknown |
| 7 | } catch { |
| 8 | return text |
| 9 | } |
| 10 | } |
| 11 | |
| 12 | export function looksJson(result: CallResult) { |
| 13 | return result.contentType.includes("application/json") || result.text.startsWith("{") || result.text.startsWith("[") |