Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. function getjson1() {
  2. return {
  3. 'json1': {
  4. id: 'jsonid1'
  5. }
  6. };
  7. }
  8.  
  9. function getjson2() {
  10. return {
  11. 'json2': {
  12. id: 'jsonid2'
  13. }
  14. };
  15. }
  16.  
  17. myjson = [];
  18.  
  19. myjson.push(getjson1());
  20.  
  21. myjson.push(getjson2());
  22.  
  23. function finaljson() {
  24. return {
  25. 'json': myjson
  26. };
  27. }
  28.  
  29. console.log(JSON.stringify(finaljson()));
  30.  
  31. {"json":[{"json1":{"id":"jsonid1"}},{"json2":{"id":"jsonid2"}}]}
  32.  
  33. {"json":{"json1":{"id":"jsonid1"},"json2":{"id":"jsonid2"}}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement