Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. this.unroll(this.dataa.GENERIC_ROUGHDRAFT.LINE_ITEM_DETAIL);
  2. console.log(this.arr);
  3. }
  4.  
  5. arr = [];
  6.  
  7. unroll(obj: any) {
  8. if (Array.isArray(obj)) {
  9. obj.forEach(e => {
  10. this.unroll(e);
  11. });
  12. } else if (typeof obj === 'object' && obj !== null) {
  13. const keys = Object.keys(obj);
  14. keys.forEach(e => {
  15. if (e === 'ITEMS') {
  16. if (Array.isArray(obj.ITEMS.ITEM)) {
  17. this.arr.push(...obj.ITEMS.ITEM);
  18. } else {
  19. this.arr.push(obj.ITEMS.ITEM);
  20. }
  21. }
  22. this.unroll(obj[e]);
  23. });
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement