Can I easily delete 'blank' rows in an array?

I have part of a form which works well. The results of which are entered into a single Database Field as json. There are 5 rows shown here but the user can add as many rows as they need and then submit the form.

If there are any ‘blank’ rows, or at least the ‘part’ has a blank value, then I don’t want those ‘blank’ rows to process or put another way, I want to remove them before they are uploaded to the Database. How can I do that?

All these fields use the name 'name="method_item[]"' which puts everything into an array.

Here is the view in DevTools.

image

And here is the json as it is uploaded into the Database field.

[
{"part":"Front Bumper Cover","replace":"1","repair":"0","paint":"0"},
{"part":"O\/S\/F Wing","replace":"0","repair":"1","paint":"1"},
{"part":"O\/S\/F Washer Bottle","replace":"1","repair":"0","paint":"1"},
{"part":"","replace":"0","repair":"0","paint":"0"},
{"part":"","replace":"0","repair":"0","paint":"0"}
]
Community Page
Last updated: