import _ from "lodash";
import {beautify} from "../formatter/html";
const convert = (json = [], {header = true} = {}) => {
if (!_.isArray(json) || json.length < 1) {
return ""
}
let html = ["
"];
let keys = Object.keys(json[0])
if (header) {
html.push(
'',
'',
...keys.map((item) => {
return `${item} | `
}),
'
',
''
)
}
html.push("")
for (let row of json) {
html.push("", ...keys.map((item) => {
return `${item in row ? row[item] : ""} | `
}), '
');
}
html.push("
")
return beautify(html.join(""))
}
export default convert