Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.unroll(this.dataa.GENERIC_ROUGHDRAFT.LINE_ITEM_DETAIL);
- console.log(this.arr);
- }
- arr = [];
- unroll(obj: any) {
- if (Array.isArray(obj)) {
- obj.forEach(e => {
- this.unroll(e);
- });
- } else if (typeof obj === 'object' && obj !== null) {
- const keys = Object.keys(obj);
- keys.forEach(e => {
- if (e === 'ITEMS') {
- if (Array.isArray(obj.ITEMS.ITEM)) {
- this.arr.push(...obj.ITEMS.ITEM);
- } else {
- this.arr.push(obj.ITEMS.ITEM);
- }
- }
- this.unroll(obj[e]);
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement