Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion jsroot/jsroot_reader.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export async function read(input, output, fields, preprocess, args) {
}

export function writeJson(dict_input, output, { marker } = {}) {
let dict_string = JSON.stringify(dict_input, null, 2);
let dict_string =
dict_input.length === 0 ? "[\n]" : JSON.stringify(dict_input, null, 2);
dict_string += "\n"; // read.C macro have an empty new line at the end

// create folder if not exist and output contains folder path
Expand Down
8 changes: 8 additions & 0 deletions jsroot/structure/empty/read.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { read } from "../../jsroot_reader.mjs";

const fields = ["Int32"];

const [input = "structure.empty.root", output = "structure.empty.json"] =
process.argv.slice(2);

read(input, output, fields);
15 changes: 15 additions & 0 deletions jsroot/types/pair/read.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { read } from "../../jsroot_reader.mjs";

function processPair(obj) {
if (Array.isArray(obj)) return obj.map(processPair);
if (obj && typeof obj === "object")
return [processPair(obj.first), obj.second];
return obj;
}

const fields = ["Int32_String", "Variant_Vector", "Pair", "VectorPair"];

const [input = "types.pair.root", output = "types.pair.json"] =
process.argv.slice(2);

read(input, output, fields, processPair);