JSX compiles to createElement(type, props, ...children). Implement it to return {"type", "props", "children"}. Input: line 1 — type; line 2 — props JSON; line 3 — children JSON array. Print the element JSON.
Input: three lines. Output: the element object as JSON.
Your program reads from stdin and prints to stdout.
Example 1
Input: div {"id":"app"} ["hi"]
Output: {"type":"div","props":{"id":"app"},"children":["hi"]}
Hints
JSX compiles to createElement(type, props, ...children). Implement it to return {"type", "props", "children"}. Input: line 1 — type; line 2 — props JSON; line 3 — children JSON array. Print the element JSON.
Input: three lines. Output: the element object as JSON.
Your program reads from stdin and prints to stdout.
Example 1
Input: div {"id":"app"} ["hi"]
Output: {"type":"div","props":{"id":"app"},"children":["hi"]}
Hints