I Want Turn JS Code Execution to JSON Execution

  execution, javascript, json, node.js

I’m currently trying boilerplate for All Scraping Tools (Puppeteer, axios)
and i want it’s call using JSON

so here the config should look like

  'module': 'puppetter',
  'method': 'new_page',
  'as': 'page',
  'use': 'page',
  'method': 'goto',
  'params': {
    'url': 'https://google.com/',
    'waitUntil': 'networkidle0',
}, {
 'use': 'page',
 'method': 'evaluate',
 'eval': `(() => {
     return document.querySelector('title').textContent

and the code execution i tried now

let x = []
if (module == 'puppeteer') {
   let m = require(module)
   await m.launch(opts)
   x[as] = await m.newPage()
if (use) {
   let v = x[use]
   if (method == 'goto') {
       await v.goto(params)

it’s nice is not it? i imagine if we can turn the code to JSON
so i’m just send POST the config to HTTP Server

i tried looking on google too, but it’s confuse me since the result is JSON.stringfy

Any idea, research have done, other language done something like that, library, npm, it’s posible ?

i can do manual but it’s lot more time since i need to translate whole everything

Source: Ask Javascript Questions