Z
Z
Zakharov Alexander2015-02-09 11:04:12
JavaScript
Zakharov Alexander, 2015-02-09 11:04:12

Is there a JSON filter as opposed to jQuery.extend/merge?

Hello colleagues.
I am looking for a JavaScript function that will allow me to leave only the necessary nodes in a multilevel json object. Is there such a thing in mind?
Example:
json object:
obj = {"fio":{"name":"nameValue2", "surname":"surnameValue2", "patronymic":"patronimicValue2", "arrOrganization":[{"id":"id21" , "name":"oName21"}, {"name":"oName22"}], "propJson":{"prop1":"value1", "prop2":"value2"}}}
It is necessary to leave only the fields in it "fio.name", "fio.surname", "fio.arrOrganization" (but only "id", no name):
{"fio":{"name":"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Melnikov, 2015-02-09
@mlnkv

and you may ask why?

S
Sergey, 2015-02-09
Protko @Fesor

lodash will help you.
updated, based on your comment (which should be put in the question description) you need to do it all based on ngModel and $touched/$dirty input properties. Not?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question