How to record only received the keys from the Json?

Hello everyone, the server returns a result in json:

response: { 
messages: 6 

And there's a list, with data-attributes, for example

<p data-name="messages"></p>
<p data-name="friends"></p>
<p data-name="gifts"></p>

How to Jquery/js to get rid of the answer and write only the existing keys in the html code of the tag? That is, the server may not return all existing

That is, messages in the response corresponds to data-name="messages" and so on
July 4th 19 at 23:30
3 answers
July 4th 19 at 23:32
To obtain the object's keys through the odds
For(var key in obj){.... console.log(key);}
July 4th 19 at 23:34
July 4th 19 at 23:36

Find more questions by tags JavaScriptjQueryJSON