I'm creating a project where I have a Django server sending JSON data to a template which has Vue.js running on it. The JSON data is sending values with a trailing space after them which is causing problems. I'd like to remove them on the HTML page if possible.
I've tried using Javascript.trim() on the JSON data which didn't seem to have any effect. I also can't strip the entire JSON file of whitespace, since some values need to have whitespace in them.
I am trying to remove whitespace from {"keyword" : "value"} sets. The "value" section sometimes has "value " or " value" in them.
This won't work
<option value="And">And</option>
But this will
<option value="And ">And</option>
The JSON object contains
"keyword": "And "
Instead of
"keyword": "And"
I expect the tag to work regardless of the whitespace surrounding the value in the data.
Edit: I can't use Javascript's trim() function, since there are dozens of occurences of the issue in the JSON data. Looping through the data and trimming each individual string would significantly increase the load times for the page.
Edit2:
<b-form-select for="action-text" v-model="step.keyword" class="mx-3">
<option value="Given ">Given</option>
<option value="When ">When</option>
<option value="Then ">Then</option>
<option value="And ">And</option>
<option value="But ">But</option>
</b-form-select>
Where in this would I do as needed trimming?