Skip to content

Instantly share code, notes, and snippets.

@richardhughes260
Created April 1, 2013 22:49
Show Gist options
  • Save richardhughes260/5288427 to your computer and use it in GitHub Desktop.
Save richardhughes260/5288427 to your computer and use it in GitHub Desktop.
odd behavior with structFindValue & JSON true
<cfsavecontent variable="variables.scString">{"username": "MinerAccount", "rating": "none", "confirmed_nmc_reward": "0.00000000", "send_threshold": "1.00000000", "nmc_send_threshold": "10.00000000", "confirmed_reward": "0.58411453", "workers": {"MinerAccount.sif": {"last_share": 1364237399, "score": "0", "hashrate": 0, "shares": 0, "alive": false}, "MinerAccount.loki": {"last_share": 1317347573, "score": "0", "hashrate": 0, "shares": 0, "alive": false}, "MinerAccount.odin": {"last_share": 1329744778, "score": "0", "hashrate": 0, "shares": 0, "alive": false}, "MinerAccount.dog": {"last_share": 1364850934, "score": "29285.8037", "hashrate": 2040, "shares": 2816, "alive": true}, "MinerAccount.Freyr": {"last_share": 1364440355, "score": "0", "hashrate": 0, "shares": 0, "alive": false}}, "wallet": "REDACTED", "unconfirmed_nmc_reward": "0.00000000", "unconfirmed_reward": "0.19413921", "estimated_reward": "0.00218734", "hashrate": "3094.363"}</cfsavecontent>
<!---
<cfdump var="#variables.scString#">
<cfdump var="#deserializeJSON(variables.scString)#">
--->
<cfscript>
variables.data = deserializeJSON(variables.scString);
variables.miner = {};
variables.miner.confirmed_reward = data.confirmed_reward;
variables.miner.unconfirmed_reward = data.unconfirmed_reward;
variables.miner.total_reward = variables.miner.unconfirmed_reward + variables.miner.confirmed_reward;
variables.miner.liveWorker = structFindValue(data.workers, true, "all");
variables.miner.dog = data.workers[ 'MinerAccount.dog'];
variables.miner.cat=variables.miner.dog.alive;
variables.miner.livedog = structFindValue(variables.miner.dog, variables.miner.cat, "all");
</cfscript>
<cfset cat=variables.miner.dog.alive >
<cfdump var="#variables.miner.dog#" metainfo="yes" label="dog">
<hr>
<cfdump var="#variables.miner.dog.alive#" label="dog.alive">
<hr>
<cfdump var="#variables.miner#" label="entire Struct">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment