Answer the question
In order to leave comments, you need to log in
How to process data if an array of objects or just an object can come?
Hello. Tell me please. I receive data in the form of a JSON file. The structure is something like this:
"Адрес":[
{
"Регион":{
"ТипРегион":"область",
"НаимРегион":"Свердловская"
}
}, ...
}, ...
]
Answer the question
In order to leave comments, you need to log in
Do something like:
input = Array.isArray(input) ? input: [input];
// дальше работаем с input как с массивом
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question