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

Function json

packages/opencode/src/provider/error.ts:73–87  ·  view source on GitHub ↗
(input: unknown)

Source from the content-addressed store, hash-verified

71}
72
73function json(input: unknown) {
74 if (typeof input === "string") {
75 try {
76 const result = JSON.parse(input)
77 if (result && typeof result === "object") return result
78 return undefined
79 } catch {
80 return undefined
81 }
82 }
83 if (typeof input === "object" && input !== null) {
84 return input
85 }
86 return undefined
87}
88
89export type ParsedStreamError =
90 | {

Callers 2

parseStreamErrorFunction · 0.70
parseAPICallErrorFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected