Thursday, 7 November 2019

Parsing Gremlin console output into JSON (with node)


JSON.parse("[" + str.trim().replace(/==>/g,"").replace(/\n/,",").replace(/([a-zA-Z0-9]+)=/g, '"$1": ').replace(/\[([a-zA-Z0-9_.//]+)\]/g, '["$1"]').replace(/\["(\d+)"\]/g, "[$1]").trim() + "]")