I am writing some data to a file with writeJSON from the lang::json::IO module.
Example:
map[str, value] volumeMetrics = ();
map[str path, map[loc location, int lineCount] methods] = ...; // some data
volumeMetrics["files"] = methodLineCountPerFile;
How can I control the names of the properties in the resulting JSON without going through the hierarchy of objects and specifying them manually? In this particular case I would want the JSON objects to have properties named after the labels defined in the map (e.g. "path", "location", "linecount", "methods"). Instead, this data is now directly written as object properties.
(partial) sample output:
"/src/smallsql/database/ExpressionFunctionUCase.java": [
[
{
"scheme": "java+compilationUnit",
"authority": "",
"path": "/src/smallsql/database/ExpressionFunctionUCase.java",
"offset": 1600,
"length": 32,
"begin": [
47,
41
],
"end": [
49,
2
]
},
3
],
[
{
"scheme": "java+compilationUnit",
"authority": "",
"path": "/src/smallsql/database/ExpressionFunctionUCase.java",
"offset": 1679,
"length": 80,
"begin": [
52,
41
],
"end": [
55,
2
]
},
4
],
[
{
"scheme": "java+compilationUnit",
"authority": "",
"path": "/src/smallsql/database/ExpressionFunctionUCase.java",
"offset": 1810,
"length": 78,
"begin": [
58,
43
],
"end": [
61,
2
]
},
4
],
[
{
"scheme": "java+compilationUnit",
"authority": "",
"path": "/src/smallsql/database/ExpressionFunctionUCase.java",
"offset": 1518,
"length": 35,
"begin": [
42,
25
],
"end": [
44,
2
]
},
3
]
],