@@ -80,7 +80,8 @@ export class KvDataBrowserComponent implements OnInit {
8080 }
8181
8282 openEdit ( item : KvDataItem ) {
83- this . editingItem = { key : item . key , value : item . value , expiresIn : null , isNew : false } ;
83+ const valueStr = typeof item . value === 'string' ? item . value : JSON . stringify ( item . value , null , 2 ) ;
84+ this . editingItem = { key : item . key , value : valueStr , expiresIn : null , isNew : false } ;
8485 }
8586
8687 closeEdit ( ) {
@@ -90,10 +91,19 @@ export class KvDataBrowserComponent implements OnInit {
9091 save ( ) {
9192 if ( ! this . editingItem ) return ;
9293
94+ // Try to parse as JSON, fallback to string
95+ let value : unknown = this . editingItem . value ;
96+
97+ try {
98+ value = JSON . parse ( this . editingItem . value ) ;
99+ } catch {
100+ // Keep as string if not valid JSON
101+ }
102+
93103 this . kvDataService . put (
94104 this . namespaceId ,
95105 this . editingItem . key ,
96- this . editingItem . value ,
106+ value ,
97107 this . editingItem . expiresIn ?? undefined
98108 ) . subscribe ( {
99109 next : ( ) => {
@@ -130,9 +140,12 @@ export class KvDataBrowserComponent implements OnInit {
130140 } ) ;
131141 }
132142
133- truncate ( value : string , maxLength = 100 ) : string {
134- if ( value . length <= maxLength ) return value ;
135- return value . slice ( 0 , maxLength ) + '...' ;
143+ formatValue ( value : unknown , maxLength = 100 ) : string {
144+ const str = typeof value === 'string' ? value : JSON . stringify ( value ) ;
145+
146+ if ( str . length <= maxLength ) return str ;
147+
148+ return str . slice ( 0 , maxLength ) + '...' ;
136149 }
137150
138151 formatDate ( date : string | null ) : string {
0 commit comments