From d69d8c29d9b36f5e931c41a157f0e25a72d608ed Mon Sep 17 00:00:00 2001 From: Balazs Barabas Date: Mon, 14 Oct 2024 10:42:02 +0300 Subject: [PATCH] displaying size of arrays and nr root level in title --- src/components/Results/Hit.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/Results/Hit.js b/src/components/Results/Hit.js index 0a67428..cad1840 100644 --- a/src/components/Results/Hit.js +++ b/src/components/Results/Hit.js @@ -148,6 +148,7 @@ function getFieldValueType(value) { const FieldValue = ({ hit, objectKey }) => { const fieldValueType = getFieldValueType(hit[objectKey]) + const sizeOfObject = Object.keys(hit[objectKey])?.length || 0 if (fieldValueType === 'array') { return ( @@ -155,7 +156,7 @@ const FieldValue = ({ hit, objectKey }) => { value={hit[objectKey]} hit={hit} attribute={objectKey} - title="array" + title={`array [${sizeOfObject}]`} reactJsonOptions={{ groupArraysAfterLength: 20, displayArrayKey: true }} /> ) @@ -167,7 +168,7 @@ const FieldValue = ({ hit, objectKey }) => { value={hit[objectKey]} hit={hit} attribute={objectKey} - title="json" + title={`json [${sizeOfObject}]`} reactJsonOptions={{ displayArrayKey: false }} /> )