This PR addresses the issue of handling dump.json in JSON data transformation functions and ensures human readability of Token Chain Dump output
Summary
The primary objective of this PR is to fix the panic caused by type assertions when dealing with map[interface{}]interface{} and to enhance the existing flattenKeys and applyKeyMapping functions to handle these cases correctly.
Changes Made
Conversion Function: Introduced convertMap to convert map[interface{}]interface{} to map[string]interface{}.
Updated Functions: Modified flattenKeys and applyKeyMapping functions to handle both map[string]interface{} and map[interface{}]interface{} types.
Main Function: Ensured the main function correctly processes and transforms the JSON data.
Detailed Description
convertMap Function
A new utility function, convertMap, was introduced to convert map[interface{}]interface{} to map[string]interface{}. This ensures that the map keys are always strings, avoiding type assertion issues.
flattenKeys Function
The flattenKeys function was updated to handle both map[string]interface{} and map[interface{}]interface{} types. It uses the convertMap function to ensure all keys are strings.
applyKeyMapping Function
The applyKeyMapping function was also updated to ensure that it processes maps correctly, regardless of the map type.
Usage
Generate the tokenchain dump using ./rubixgoplatform tokenchaindump -token <tokenID> which will create a dump.json file in the current path, once the tokenchaindump is completed run ./rubixgoplatform decodetokenchain which will decode the dump and save the decoded details into a new file called output.json where you can get the decoded details
Improve Readability of Token Chain Dump Output
This PR addresses the issue of handling dump.json in JSON data transformation functions and ensures human readability of Token Chain Dump output
Summary
The primary objective of this PR is to fix the panic caused by type assertions when dealing with
map[interface{}]interface{}
and to enhance the existingflattenKeys
andapplyKeyMapping
functions to handle these cases correctly.Changes Made
convertMap
to convertmap[interface{}]interface{}
tomap[string]interface{}
.flattenKeys
andapplyKeyMapping
functions to handle bothmap[string]interface{}
andmap[interface{}]interface{}
types.Detailed Description
convertMap
FunctionA new utility function,
convertMap
, was introduced to convertmap[interface{}]interface{}
tomap[string]interface{}
. This ensures that the map keys are always strings, avoiding type assertion issues.flattenKeys
FunctionThe
flattenKeys
function was updated to handle bothmap[string]interface{}
andmap[interface{}]interface{}
types. It uses theconvertMap
function to ensure all keys are strings.applyKeyMapping
FunctionThe
applyKeyMapping
function was also updated to ensure that it processes maps correctly, regardless of the map type.Usage
Generate the tokenchain dump using
./rubixgoplatform tokenchaindump -token <tokenID>
which will create adump.json
file in the current path, once the tokenchaindump is completed run./rubixgoplatform decodetokenchain
which will decode the dump and save the decoded details into a new file calledoutput.json
where you can get the decoded details