A library extracted out from https://github.com/bjartek/overflow that has less depdendencies and only parses to from go<>cadence
if you want a map[string]interface
use underflow.CadenceValueToInterface
underflow.CadenceValueToJsonString(<your cadence value>)
This will create a very terse representation
- it will skip any value that is empty/bottom type
- if a value is empty a key is skipped
If you do not like this you can configure it like this
underflow.CadenceValueToJsonStringWithOption(<your cadence value>, underflow.Options{
IncludeEmptyValues: true, //this will not skip empty values/keys
WrapWithComplexTypes: true, //this will wrap any complex types with another layer that includes the type
})
pub contract MyFancyContract {
pub struct MyStruct{
pub let owner: Address
pub let name: String
}
Create the following go struct
type MyFancyContract_MyStruct struct {
Owner string `cadence:"owner,cadenceAddress"`
Name string `cadence:"name"`
}
myImpl := MyFancyContract_MyStruct{
Owner: "0x123",
Name: "bjartek is the best"
}
//resolver is here a function that takes in the name of a go struct and returns the identifier of the cadence type on a given network
// resolver func(name string) (string, error)
err, myCadenceValue :=underflow.InputToCadence(myImp, resolver)