MCPcopy Index your code
hub / github.com/anomalyco/opencode / parse

Function parse

packages/opencode/test/server/httpapi-exercise/assertions.ts:3–10  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

1import type { CallResult, JsonObject } from "./types"
2
3export 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
12export function looksJson(result: CallResult) {
13 return result.contentType.includes("application/json") || result.text.startsWith("{") || result.text.startsWith("[")

Callers 1

captureFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected