Append and remove values at JSON array, ios sdk

“JSON Data in Database” section in ios documentation has line:
Operations on JSON arrays - appending, inserting, replacing or removing array values

BUT “Updating JSON Data” section has only " ARRAY APPEND" and " ARRAY INSERT" description.

My question is: Is it possible to remove certain value from JSON array?
For example remove “red” from array [“blue”, “red”, “green”]

Thanks.

Hello @Dmitry_Kalenkov,

I see more functions there:

My question is: Is it possible to remove certain value from JSON array?

Yes, it is possible:
https://backendless.com/docs/ios/data_updating_json_data.html#remove

Regards,
Stanislaw

Hello @stanislaw.grin! Thanks for your answer, but it’s not really what im looking for…
I’ve tried “Remove” Api from your respond and the best result i could reach is:

let profile = JSONUpdateBuilder.remove()
.addArgument(jsonPath: “$[index]”)
.create()
,where index can be 0,1,2… etc.

But i’am looking for somethig like this:
let profile = JSONUpdateBuilder.remove()
.addArgument(jsonPath: “red”)
.create()
, where red - is certan value element of array.

Regards,
Dmitry

Hi Dmitry,

As of right now, there is no function that would allow the removal of an array item by value.

Consider using Hive API instead:
https://backendless.com/docs/js/hive_overview.html

The List data structure would be very similar and it has the API to remove an item by value.

Regards,
Mark

1 Like