0.0.2 • Published 3 years ago

solidity-escapestring v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Escape String


Used to escape special characters when splicing json strings in solidity

Installation


npm install --save solidity-escapestring

Usages


Escape String

pragma solidity ^0.8.4;

import "solidity-escapestring/escapeString.sol";

contract HelloWorld {
    function main() public pure returns (string memory) {
        string memory s1 = "hello\r\nworld";

        string memory json = string(
            abi.encodePacked('{"name":"', EscapeString.toJsonValue(s1), '"}')
        );

        return json;
    }
}

Author


reloop.eth z.cejay@gmail.com

0.0.2

3 years ago

0.0.1

3 years ago