proofgeist / fm-json-additions

MIT License
27 stars 12 forks source link

JSON.ArrayLength is incorrect with empty string as value #18

Open rwu2359 opened 6 years ago

rwu2359 commented 6 years ago

If the array contains values which are an empty string i.e. "" the function will not return the correct number of items in the array Suggest changing to

_values = JSONListKeys ( _array ; path )

This will return the correct number of full or empty slots in the array

DanShockley commented 3 years ago

Here's a test that demonstrates the error: JSON.ArrayLength ( "[ 1, \"\", 3 ]" ; "" ) should give a result of 3, but instead gives 2. The suggested fix by @rwu2359 would address this error.

DanShockley commented 3 years ago

I'm having trouble attaching files to the comment above, so I will try here: I've attached a copy of the JSONAdditions.fmp12 file that give an example of the error, and a copy that includes the fix. JSONAdditions-ArrayLength-empty-string-bug-example.fmp12.zip JSONAdditions-ArrayLength-empty-string-bug-FIXED.fmp12.zip