Struggling with JSON from database field

I have some JSON saved in a database field

{"1":{"part":"O\/S\/F Wingxxx","replace":"0","repair":"0","paint":"0"},"2":{"part":"Rear Bumper","replace":"0","repair":"1","paint":"1"},"3":{"part":"O\/S\/F Repeater","replace":"0","repair":"1","paint":"0"},"4":{"part":"Chassis Leg NS","replace":"0","repair":"0","paint":"0"},"5":{"part":"gsfh sfgh","replace":"0","repair":"0","paint":"0"},"6":{"part":"vhgj gdhjg","replace":"0","repair":"0","paint":"0"},"7":{"part":"","replace":"0","repair":"0","paint":"0"},"8":{"part":"","replace":"0","repair":"0","paint":"0"},"9":{"part":"","replace":"0","repair":"0","paint":"0"},"10":{"part":"","replace":"0","repair":"0","paint":"0"}}

Then in my Action Step I do a json_decode() to put the data into a variable

Set Value TEST12 = {{sa_ad_job_q.meth_json.json_decode()}}

And this is then output on the page

<div id="myRepeat" is="dmx-repeat" dmx-bind:repeat="sc_ad_job_q.data.TEST12">
  <div id="myConditional" is="dmx-if" dmx-bind:condition="(part != '')">
	$index  : {{$index}} || 
	$key    : {{$key}} || 
	Replace : {{replace}} || 
	Part    : {{part}} || 
  </div>
</div>

So far this works well.

My problem is trying to count the total number of records (which in t6his example would be ‘10’) and the number of records by condition (which would be ‘6’).

Total number of records : {{number of records}}
Number of records by condition : {{number of condition records}}

I cannot work out for the life of me how to return these two figures. Everything I have tried fails.

I am happy for someone to tell me I am doing it all wrong, I just want to be able to make it work :smile:

Please help.

Community Page
Last updated: