MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / toMap

Function toMap

internal/search/search.go:282–300  ·  view source on GitHub ↗

toMap converts an interface{} to map[string]interface{} via JSON marshaling.

(data interface{})

Source from the content-addressed store, hash-verified

280
281// toMap converts an interface{} to map[string]interface{} via JSON marshaling.
282func toMap(data interface{}) (map[string]interface{}, error) {
283 // If already a map, return it directly
284 if m, ok := data.(map[string]interface{}); ok {
285 return m, nil
286 }
287
288 // Marshal and unmarshal to convert struct to map
289 jsonBytes, err := json.Marshal(data)
290 if err != nil {
291 return nil, err
292 }
293
294 var result map[string]interface{}
295 if err := json.Unmarshal(jsonBytes, &result); err != nil {
296 return nil, err
297 }
298
299 return result, nil
300}
301
302// processMetadata handles metadata field normalization for object schemas
303func (t *TypesenseClient) processMetadata(data map[string]interface{}) error {

Callers 7

indexLedgersMethod · 0.85
indexIdentitiesMethod · 0.85
indexBalancesMethod · 0.85
indexTransactionsMethod · 0.85
TestToMap_AlreadyMapFunction · 0.85
TestToMap_StructFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestToMap_AlreadyMapFunction · 0.68
TestToMap_StructFunction · 0.68