How can I convert a .dxf file into .json using node js?

I’ve the values of a dxf file in to form of .json file and I’am trying to convert that .json file into a .dxf file using node js

I’ve tried using this code
export const generateDXF = (i, o) => {
let dxfContent = 0nSECTIONn2nHEADERn0nENDSECn0nSECTIONn2nTABLESn0nENDSECn0nSECTIONn2nBLOCKSn0nENDSECn;
dxfContent += 0nSECTIONn2nENTITIESn;

i?.entities?.forEach((entity) => {
if (entity.type === “LINE”) {
dxfContent += 0nLINEn8n${entity.layer}n; // Layer
dxfContent += 10n${entity?.vertices[0].x}n20n${entity?.vertices[0].y}n30n${entity?.vertices[0].z}n; // Start point
dxfContent += 11n${entity?.vertices[1].x}n21n${entity?.vertices[1].y}n31n${entity?.vertices[1].z}n; // End point
}
});

dxfContent += 0nENDSECn0nEOFn; // End of DXF file
fs.writeFileSync(o, dxfContent);

return dxfContent;
};