<p></p>
<p><b>@gravitystorm</b> requested changes on this pull request.</p>

<p>This PR also needs tests. Similarly to the previous JSON-response PRs, it doesn't need to duplicate every test of the XML output, but just enough to ensure that the routes exist, and that when json is requested a suitable json-formatted response is received.</p>
<p>Have a look at test/controllers/api/users_controller_test.rb and search for 'json' to see what I mean.</p><hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/3164#discussion_r608499754">app/views/api/user_preferences/index.json.jbuilder</a>:</p>
<pre style='color:#555'>> @@ -0,0 +1 @@
+json.partial! @user_preferences
</pre>
<p>This should also contain the <code>root_elements</code>, similar to the XML response. This is already implemented for e.g. showing relations - see <a href="https://github.com/openstreetmap/openstreetmap-website/blob/master/app/views/api/relations/show.json.jbuilder">https://github.com/openstreetmap/openstreetmap-website/blob/master/app/views/api/relations/show.json.jbuilder</a></p>
<p>When those are included, it becomes clearer that there needs to be a root <code>preferences</code> (n.b. plural) key, to match the naming of the <code><preferences></code> element in the XML response.</p>
<p>So something like this:</p>
<pre><code>{
    "version": "0.6",
    "generator": "OpenStreetMap server",
    "copyright": "OpenStreetMap and contributors",
    "attribution": "http://www.openstreetmap.org/copyright",
    "license": "http://opendatacommons.org/licenses/odbl/1-0/",
    "preferences": {
        "foo": "bar",
        "another_pref": "something else",
        "more preferences": "go here"
    }
}
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/3164#pullrequestreview-629801732">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLORK2EEQROTI7BX7JDTHQSMTANCNFSM42P4F7NQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AAK2OLNATNQDY2XUZT4N2CLTHQSMTA5CNFSM42P4F7N2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOEWFAGBA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/3164#pullrequestreview-629801732",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/3164#pullrequestreview-629801732",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>