# Comma in value of comma-separated filter value list

**URL:** <https://discuss.jsonapi.org/t/comma-in-value-of-comma-separated-filter-value-list/1285>\
**Category:** Uncategorized\
**Created:** [May 4, 2018, 9:36pm UTC](https://discuss.jsonapi.org/t/comma-in-value-of-comma-separated-filter-value-list/1285 "2018-05-04T21:36:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marceloverdijk](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/marceloverdijk/32/521_2.png) [@marceloverdijk](https://discuss.jsonapi.org/u/marceloverdijk)\
**Post date:** [May 4, 2018, 9:36pm UTC](https://discuss.jsonapi.org/t/comma-in-value-of-comma-separated-filter-value-list/1285/1 "2018-05-04T21:36:45Z")

</div>

As per the spec multiple filter values can be combined with a comma.

> Multiple filter values can be combined in a comma-separated list. For example:

> `GET /comments?filter[post]=1,2 HTTP/1.1`

What if a value itself contains a comma?

like `/hotels?filter[location]=Abbey Wood, London,Manchester` where `"Abbey Wood, London"` is a single location.

---

<div class="post-metadata">

**Author:** ![ethanresnick](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@ethanresnick](https://discuss.jsonapi.org/u/ethanresnick)\
**Post date:** [May 5, 2018, 9:02am UTC](https://discuss.jsonapi.org/t/comma-in-value-of-comma-separated-filter-value-list/1285/2 "2018-05-05T09:02:14Z")

</div>

In the `?include` and `?fields` params, which are the only parameters that have their values strictly defined by the spec, this problem can’t happen because the [member naming rules](http://jsonapi.org/format/#document-member-names) disallow field names with commas in them.

For other parameters, like `?page`, and `?filter`, the spec suggests what they should be used for, but says nothing binding/normative about their syntax, so how to handle this is up to you/each implementation. One natural way would be to percent encode any commas that appear within data values, to distinguish them from commas that are acting as delimiters.

For `?sort`, there’s an open issue: [https://github.com/json-api/json-api/issues/1266](https://github.com/json-api/json-api/issues/1266)

---

<div class="post-metadata">

**Author:** ![marceloverdijk](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/marceloverdijk/32/521_2.png) [@marceloverdijk](https://discuss.jsonapi.org/u/marceloverdijk)\
**Post date:** [May 5, 2018, 8:52pm UTC](https://discuss.jsonapi.org/t/comma-in-value-of-comma-separated-filter-value-list/1285/3 "2018-05-05T20:52:11Z")

</div>

Yes thx, I think it’s good to urlencode commas in the filter value(s).
