mirror of
https://github.com/apache/superset.git
synced 2026-04-21 00:54:44 +00:00
feat: Add parseJson Handlebars Helper to Support Processing Nested JSON Data (#31998)
Co-authored-by: AdrianKoszalka <adrian.koszalka@techminers.com>
This commit is contained in:
@@ -99,5 +99,18 @@ Handlebars.registerHelper(
|
||||
},
|
||||
);
|
||||
|
||||
// usage: {{parseJson jsonString}}
|
||||
Handlebars.registerHelper('parseJson', (jsonString: string) => {
|
||||
try {
|
||||
return JSON.parse(jsonString);
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
error.message = `Invalid JSON string: ${error.message}`;
|
||||
throw error;
|
||||
}
|
||||
throw new Error(`Invalid JSON string: ${String(error)}`);
|
||||
}
|
||||
});
|
||||
|
||||
Helpers.registerHelpers(Handlebars);
|
||||
HandlebarsGroupBy.register(Handlebars);
|
||||
|
||||
Reference in New Issue
Block a user