Our organization has two approaches to the problem:
- Sending data as JSON as opposed to POST-data is a good all-purpose approach, though this is sometimes a little bit difficult to integrate with frameworks like Rails, because you may have to add explicit back-end calls to decode the JSON data.
[""]
as noted by vinod will work well, as many frameworks (e.g. Rails) will often treat this as an empty array. (for the reason, see this Stack Overflow answer).- Note: This works when trying to integrate with some aspects of Rails, specifically when sending a list of ids of objects that are related by a
has_many
relationship. E.g. if you have afoos
table and abars
table, andfoos
has_many :bars through :foo_bars
, a way to remove all associations on afoo
object is to passfoo: { bar_ids: [""] }
.
- Note: This works when trying to integrate with some aspects of Rails, specifically when sending a list of ids of objects that are related by a
Both approaches are hackier than desired, and I would be glad to discover a cleaner approach.