codecov-io: # [Codecov](https://codecov.io/gh/Azure/msrest-for-python/pull/167?src=pr&el=h1) Report
> Merging [#167](https://codecov.io/gh/Azure/msrest-for-python/pull/167?src=pr&el=desc) into [master](https://codecov.io/gh/Azure/msrest-for-python/commit/c4086bfac4e45b11b6bd4267cff62aa302a51877?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/Azure/msrest-for-python/pull/167/graphs/tree.svg?width=650&token=Lny6ZO1MUF&height=150&src=pr)](https://codecov.io/gh/Azure/msrest-for-python/pull/167?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #167      +/-   ##
==========================================
+ Coverage   87.84%   87.84%   +<.01%     
==========================================
  Files          25       25              
  Lines        2583     2584       +1     
==========================================
+ Hits         2269     2270       +1     
  Misses        314      314
```


| [Impacted Files](https://codecov.io/gh/Azure/msrest-for-python/pull/167?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [msrest/pipeline/universal.py](https://codecov.io/gh/Azure/msrest-for-python/pull/167/diff?src=pr&el=tree#diff-bXNyZXN0L3BpcGVsaW5lL3VuaXZlcnNhbC5weQ==) | `95.09% <100%> (+0.04%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Azure/msrest-for-python/pull/167?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Azure/msrest-for-python/pull/167?src=pr&el=footer). Last update [c4086bf...852f412](https://codecov.io/gh/Azure/msrest-for-python/pull/167?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

diff --git a/msrest/pipeline/universal.py b/msrest/pipeline/universal.py
index f124ea7..b8dc40c 100644
--- a/msrest/pipeline/universal.py
+++ b/msrest/pipeline/universal.py
@@ -32,6 +32,7 @@ import os
 import xml.etree.ElementTree as ET
 import platform
 import codecs
+import re
 
 from typing import Mapping, Any, Optional, AnyStr, Union, IO, cast, TYPE_CHECKING  # pylint: disable=unused-import
 
@@ -129,10 +130,9 @@ class HTTPLogger(SansIOHTTPPolicy):
 
 class RawDeserializer(SansIOHTTPPolicy):
 
-    JSON_MIMETYPES = [
-        'application/json',
-        'text/json' # Because we're open minded people...
-    ]
+    # Accept "text" because we're open minded people...
+    JSON_REGEXP = re.compile(r'^(application|text)/([a-z+.]+\+)?json$')
+
     # Name used in context
     CONTEXT_NAME = "deserialized_data"
 
@@ -165,7 +165,7 @@ class RawDeserializer(SansIOHTTPPolicy):
         if content_type is None:
             return data
 
-        if content_type in cls.JSON_MIMETYPES:
+        if cls.JSON_REGEXP.match(content_type):
             try:
                 return json.loads(data_as_str)
             except ValueError as err:

Response content type json parser
Currently the deserializer only supports a list of content type values like "application/json" and "text/json".  Based on HTTP spec, "application/<randomtext>+json" is also json. So we should have a type parser to accept this syntax. 
diff --git a/tests/test_universal_pipeline.py b/tests/test_universal_pipeline.py
index 2568e34..cd92ca7 100644
--- a/tests/test_universal_pipeline.py
+++ b/tests/test_universal_pipeline.py
@@ -151,6 +151,12 @@ def test_raw_deserializer():
     result = response.context["deserialized_data"]
     assert result["success"] is True
 
+    # Simple JSON with complex content_type
+    response = build_response(b'{"success": true}', content_type="application/vnd.microsoft.appconfig.kv+json")
+    raw_deserializer.on_response(None, response, stream=False)
+    result = response.context["deserialized_data"]
+    assert result["success"] is True
+
     # JSON with UTF-8 BOM
     response = build_response(b'\xef\xbb\xbf{"success": true}', content_type="application/json; charset=utf-8")
     raw_deserializer.on_response(None, response, stream=False)

pip install -e .[async]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-asyncio httpretty mock futures mypy pylint trio
apt-get update apt-get install -y gcc libunwind8-dev
3.6
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
aiodns==3.2.0
aiohttp==3.8.6
aiosignal==1.2.0
astroid==2.11.7
async-generator==1.10
async-timeout==4.0.2
asynctest==0.13.0
attrs==22.2.0
certifi==2021.5.30
cffi==1.15.1
charset-normalizer==2.0.12
contextvars==2.4
coverage==6.2
dill==0.3.4
frozenlist==1.2.0
futures==2.2.0
httpretty==1.1.4
idna==3.10
idna-ssl==1.1.0
immutables==0.19
importlib-metadata==4.8.3
iniconfig==1.1.1
isodate==0.6.1
isort==5.10.1
lazy-object-proxy==1.7.1
mccabe==0.7.0
mock==5.2.0
-e git+https://github.com/Azure/msrest-for-python.git@c4086bfac4e45b11b6bd4267cff62aa302a51877#egg=msrest
multidict==5.2.0
mypy==0.971
mypy-extensions==1.0.0
oauthlib==3.2.2
outcome==1.1.0
packaging==21.3
platformdirs==2.4.0
pluggy==1.0.0
py==1.11.0
pycares==4.3.0
pycparser==2.21
pylint==2.13.9
pyparsing==3.1.4
pytest==7.0.1
pytest-asyncio==0.16.0
pytest-cov==4.0.0
requests==2.27.1
requests-oauthlib==2.0.0
six==1.17.0
sniffio==1.2.0
sortedcontainers==2.4.0
tomli==1.2.3
trio==0.19.0
typed-ast==1.5.5
typing_extensions==4.1.1
urllib3==1.26.20
wrapt==1.16.0
yarl==1.7.2
zipp==3.6.0

name: msrest-for-python
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - aiodns==3.2.0
      - aiohttp==3.8.6
      - aiosignal==1.2.0
      - astroid==2.11.7
      - async-generator==1.10
      - async-timeout==4.0.2
      - asynctest==0.13.0
      - attrs==22.2.0
      - cffi==1.15.1
      - charset-normalizer==2.0.12
      - contextvars==2.4
      - coverage==6.2
      - dill==0.3.4
      - frozenlist==1.2.0
      - futures==2.2.0
      - httpretty==1.1.4
      - idna==3.10
      - idna-ssl==1.1.0
      - immutables==0.19
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - isodate==0.6.1
      - isort==5.10.1
      - lazy-object-proxy==1.7.1
      - mccabe==0.7.0
      - mock==5.2.0
      - multidict==5.2.0
      - mypy==0.971
      - mypy-extensions==1.0.0
      - oauthlib==3.2.2
      - outcome==1.1.0
      - packaging==21.3
      - platformdirs==2.4.0
      - pluggy==1.0.0
      - py==1.11.0
      - pycares==4.3.0
      - pycparser==2.21
      - pylint==2.13.9
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-asyncio==0.16.0
      - pytest-cov==4.0.0
      - requests==2.27.1
      - requests-oauthlib==2.0.0
      - six==1.17.0
      - sniffio==1.2.0
      - sortedcontainers==2.4.0
      - tomli==1.2.3
      - trio==0.19.0
      - typed-ast==1.5.5
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - wrapt==1.16.0
      - yarl==1.7.2
      - zipp==3.6.0
prefix: /opt/conda/envs/msrest-for-python

tests/test_universal_pipeline.py::test_raw_deserializer
tests/test_universal_pipeline.py::test_user_agent tests/test_universal_pipeline.py::test_no_log
msrest/pipeline/universal.py
msrest/pipeline/universal.py