Solidity JSON – How to Store JSON String in Solidity

go-ethereumquorumsolidity

I have trying to store a JSON string in my solidity code string variable, it only stores the string on the constructor, but if try and store the same data in the function call it never saves it.

contract BOLData {

    string public SData;
    string public SCData;


    function BOLData(string S_Data) 
    { 
        SData= S_Data;
        SCData= '';
    } 
    function getSData() constant returns (string retVal) 
    { 
        return SData;
    }
    function setSCData(string SC_Data) 
    { 
        SCData = SC_Data; 
    } 
    function getSCData() constant returns (string retVal) 
    { 
        return SCData;
    }

}

Best Answer

Just gave it a try on Remix and seems to be working fine. using setSCData() does modify the value of SCData.

Maybe you are getting confused by the name of your variables... In the constructor you are setting SData but then the set function only deals with SCData, there's no function to update SData value.