How to convert json array to javascript array using specific values -


i want convert json array (string) javascript array using specific values. json array :

[{"id":47,"libelle":"famille de test"},{"id":1,"libelle":"geolocalisation"},{"id":4,"libelle":"outils"},{"id":2,"libelle":"proprete"},{"id":3,"libelle":"urgence"}] 

and want ["famille de test", "geolocalisation", ...] using libelle values. tried use $.map didn't work out.

the map implementation should work:

var jsonstr = '[{"id":47,"libelle":"famille de test"},{"id":1,"libelle":"geolocalisation"},{"id":4,"libelle":"outils"},{"id":2,"libelle":"proprete"},{"id":3,"libelle":"urgence"}]';  var arr = json.parse(jsonstr); var libelle = arr.map(function(x) { return x.libelle; }); 

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -