MCPcopy
hub / github.com/BuilderIO/mitosis / jsonObjectToAst

Function jsonObjectToAst

packages/core/src/parsers/jsx/ast.ts:35–53  ·  view source on GitHub ↗
(json: JSONOrNodeObject)

Source from the content-addressed store, hash-verified

33};
34
35const jsonObjectToAst = (json: JSONOrNodeObject): babel.types.Expression => {
36 if (!json) {
37 // TO-DO: This looks concerning...
38 return json as any;
39 }
40 const properties: babel.types.ObjectProperty[] = [];
41 for (const key in json) {
42 const value = json[key];
43 if (value === undefined) {
44 continue;
45 }
46 const keyAst = types.stringLiteral(key);
47 const valueAst = jsonToAst(value);
48 properties.push(types.objectProperty(keyAst, valueAst as any));
49 }
50 const newNode = types.objectExpression(properties);
51
52 return newNode;
53};

Callers 1

jsonToAstFunction · 0.85

Calls 2

jsonToAstFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected