MCPcopy
hub / github.com/loggerhead/json4u / urlToJSON

Function urlToJSON

src/lib/worker/command/urlToJSON.ts:4–17  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

2import { parseJSON } from "@/lib/parser";
3
4export async function urlToJSON(text: string): Promise<{ text: string; parse: boolean }> {
5 if (!text.trim()) {
6 return { text, parse: false };
7 }
8
9 const options = (await getConfig()).parseOptions;
10
11 try {
12 const tree = parseJSON(mapStringify(urlToMap(text)), options);
13 return { text: tree.text, parse: tree.valid() };
14 } catch (e) {
15 return { text, parse: false };
16 }
17}
18
19export function urlToMap(s: string, maxLevel?: number): Map<string, string | Map<string, any>> {
20 const isFullURI = isURI(s);

Callers 1

urltojson.test.tsFile · 0.90

Calls 5

getConfigFunction · 0.90
parseJSONFunction · 0.90
mapStringifyFunction · 0.85
urlToMapFunction · 0.85
validMethod · 0.80

Tested by

no test coverage detected