How to use the fabric-contract-api.JSONSerializer function in fabric-contract-api

To help you get started, we’ve selected a few fabric-contract-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / fabric-chaincode-node / libraries / fabric-shim / lib / contract-spi / bootstrap.js View on Github external
static getInfoFromContract(modulePath) {
        const modPath = path.resolve(process.cwd(), modulePath);
        const jsonPath = path.resolve(modPath, 'package.json');
        // let's find the package.json file
        const json = require(jsonPath);
        logger.debug('starting up and reading package.json at %s', jsonPath);
        logger.debug('read JSON', json);
        const JSONSerializer = require('fabric-contract-api').JSONSerializer;
        const defaultSerialization = {
            transaction: 'jsonSerializer',
            serializers: {
                jsonSerializer : JSONSerializer

        if (json.main) {
            logger.debug('Using the main entry %s', json.main);
            const p = (path.resolve(modPath, json.main));
            const r = require(p);

            // setup the set of serializers that can be used
            let serializers;
            if (!r.serializers) {
                serializers = defaultSerialization;