@gala-chain/chaincode • Readme | API
@gala-chain/chaincode / GalaJSONSerializer
Class: GalaJSONSerializer
Buffers are converted to the format of {type:'Buffer', data:xxxxx } If an object has a toJSON() method then that will be used - as this uses serialize() from @gala-chain/sdk
Constructors
new GalaJSONSerializer()
new GalaJSONSerializer():
GalaJSONSerializer
Returns
Methods
_fromString()
_fromString(
stringData
,fullschema
,loggerPrefix
):object
Parameters
• stringData: string
• fullschema: any
• loggerPrefix: any
Returns
object
jsonForValidation
jsonForValidation:
any
value
value:
any
Source
chaincode/src/utils/GalaJSONSerializer.ts:101
fromBuffer()
fromBuffer(
data
,fullschema
,loggerPrefix
):object
Inflates the data to the object or other type
If on inflation the object has a type field that will throw an error if it is not 'Buffer'
Parameters
• data: any
byte buffer containing the data
• fullschema: any
• loggerPrefix: any
Returns
object
the resulting type
jsonForValidation
jsonForValidation:
any
value
value:
any
Source
chaincode/src/utils/GalaJSONSerializer.ts:86
toBuffer()
toBuffer(
result
,schema
,loggerPrefix
?):undefined
|Buffer
Takes the result and produces a buffer that matches this serialization format
Parameters
• result: any
to be converted
• schema= {}
• schema.type?: string
• loggerPrefix?: string
Returns
undefined
| Buffer
container the encoded data