There is such a JSON string:

[ { "room_name":"GUEST1_/#hci2aC-nD_EeQDzuAAAB", "owner":"/#hci2aC-nD_EeQDzuAAAB", "name_owner":"GUEST1" }, { "room_name":"GUEST2_/#wslEqNbGi_feQ_9RAAAC", "owner":"/#wslEqNbGi_feQ_9RAAAC", "name_owner":"GUEST2" } ] 

After parsing in Nodejs, the corresponding object is obtained.

How can I completely remove one array by value, for example "owner", so that only another string is left?

Or is it necessary to somehow parse not into objects, but into an associative array and already work with it?

  • What a mess with the definitions of arrays and objects? - Grundy
  • Yes, trouble with that. I read about them, but did not understand the difference, if you just use JSON.parse (); - Literate
  • In fact, everything is simple: if square brackets - [] is an array, if curly - {} is an object - Grundy

1 answer 1

You can use the filter function to filter array.

 var res = arr.filter(el=>el.owner != ...) 

In res will return the lines in which the owner is not equal to the specified