diff --git a/src/Dataframe.js b/src/Dataframe.js index 55ffe1e..ae9c425 100644 --- a/src/Dataframe.js +++ b/src/Dataframe.js @@ -4,12 +4,32 @@ * JSON viewer for log entries. Clicking on a property _value_ * adds it to the log viewer. * - * TODO: support clicking on the property name as well, or support an - * icon or other UI element (similar to copy to clip board). */ import ReactJson from "react-json-view"; + function Dataframe(props) { - return ; + return ( + { + if (field.name === "root") { + return false; + } + + if (field.name === "request" && field.namespace[0] === "root") { + return false; + } + + if (field.name === "vehicle" && field.namespace[0] === "root" && field.namespace[1] === "request") { + return false; + } + + // Collapse everything else + return true; + }} + /> + ); } // TODO: Ideas: allow selecting a field and see how it changes along the map diff --git a/src/localStorage.js b/src/localStorage.js index a05abad..0e1f7a4 100644 --- a/src/localStorage.js +++ b/src/localStorage.js @@ -126,12 +126,28 @@ async function processJsonFile(file) { export function parseJsonContent(content) { log("Parsing JSON content"); + + const sortObjectKeys = (obj) => { + if (obj === null || typeof obj !== "object" || Array.isArray(obj)) { + return obj; + } + + return Object.keys(obj) + .sort() + .reduce((sorted, key) => { + sorted[key] = sortObjectKeys(obj[key]); + return sorted; + }, {}); + }; + try { - return JSON.parse(content); + const parsed = JSON.parse(content); + return sortObjectKeys(parsed); } catch (error) { log("Initial JSON parsing failed, attempting to wrap in array"); try { - return JSON.parse(`[${content}]`); + const parsed = JSON.parse(`[${content}]`); + return sortObjectKeys(parsed); } catch (innerError) { console.error("JSON parsing error:", innerError); throw new Error(`Invalid JSON content: ${innerError.message}`);