Help/advice needed for manipulating JSON

This part of my system works well. I allow the user to fill as many, or as few, text inputs as they need and that information is saved as JSON and stored in a single database field. This can then be retrieved and used in different situations, and as I say it works well.

There is one BIG problem though.

If the user leaves one of the fields blank within a group of fields, it throws the array indexing out as shown in the 3rd and 4th screenshots. The data is saved to the database and is pulled from the database OK but Data Bindings do not work as expected. In fact nothing shows on screen.

As an example of what happens, I have 'sc_ad_job_q.data.TEST12.count()' which simply counts the number of rows/items in the array (terminology may be wrong here).

  • In the first example I get a result = 6

  • In the second example I get a result = [blank]
    ie no result even though the JSON shows 6 rows/items correctly in DevTools albeit not sequential numbering.

How can I correct this issue?

image

image

image

image