add charts to export api

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-06-12 22:05:21 +02:00
parent 3af1882d1e
commit f20cca6e15
8 changed files with 289 additions and 181 deletions

View File

@@ -0,0 +1,19 @@
import { getSafeJson } from '@openpanel/common';
export const parseQueryString = (obj: Record<string, any>): any => {
return Object.fromEntries(
Object.entries(obj).map(([k, v]) => {
if (typeof v === 'object') return [k, parseQueryString(v)];
if (!isNaN(parseFloat(v))) return [k, parseFloat(v)];
if (v === 'true') return [k, true];
if (v === 'false') return [k, false];
if (typeof v === 'string') {
if (getSafeJson(v) !== null) {
return [k, getSafeJson(v)];
}
return [k, v];
}
return [k, null];
})
);
};