// run: // serde_dialog test2.json -o test2_json.db // souffle test2_json_query.dl // return the total population of New York City according to the 2020 census // by aggregating borough population counts #include "../schemas/serde_string_key.dl" .decl boroPopulation(boro: ElemId, population: number) boroPopulation(boro, population) :- rootElem(_, root), map(root, "boroughs", boroList), seq(boroList, _, boro), map(boro, "population", popId), number(popId, population). .decl totalPopulation(total: number) totalPopulation(sum pop : { boroPopulation(_, pop) }). .input rootElem, type, bool, number, string, map, struct, seq, tuple, structType, variantType(IO=sqlite, dbname="test2_json.db") .output totalPopulation(IO=stdout)