Guest User

Untitled

a guest
Dec 11th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. {
  2. "subscriptionId" : "5a268a598dc68904bbc7b3cf",
  3. "originator" : "localhost",
  4. "contextResponses" : [
  5. {
  6. "contextElement" : {
  7. "type" : "Temperatura",
  8. "isPattern" : "false",
  9. "id" : "S_Temp001",
  10. "attributes" : [
  11. {
  12. "name" : "Tem_int",
  13. "type" : "float",
  14. "value" : 2,
  15. "metadatas" : [
  16. {
  17. "name" : "accuracy",
  18. "type" : "Float",
  19. "value": 2 }
  20. ]
  21. },
  22. {
  23. "name" : "Tem_out",
  24. "type" : "Integer",
  25. "value" : 1
  26. }
  27. ]
  28. },
  29. "statusCode" : {
  30. "code" : "200",
  31. "reasonPhrase" : "OK"
  32. }
  33. }
  34. ]
  35. }
  36.  
  37. var json = {
  38. "name": {
  39. "first": "Yosuke",
  40. "family": "Kyra"
  41. },
  42. "birth": {
  43. "year": 1982,
  44. "month": 12,
  45. "day": 5
  46. }
  47. }
  48. // Destructuring
  49. var {name: { family: familyName }, birth: {day: birthDay}} = json
  50. console.log(familyName) // return Kyra
  51. console.log(birthDay) // return 5
  52.  
  53. var json = {
  54. // tu Json
  55. };
  56. for (var ele in json) {
  57. //aquĆ­ para los que son objetos
  58. if (typeof(json[ele]) == 'object') {
  59. eachobject(json[ele]);
  60. } else {
  61. console.log('ele --> ', ele, ' - ', json[ele]);
  62. console.log('typo del ele --> ', typeof(json[ele]));
  63. console.log(' --------------------- ');
  64. }
  65. }
  66.  
  67. function eachobject(json) {
  68. for (var ele in json) {
  69. if (typeof(json[ele]) == 'object') {
  70. eachobject(json[ele]);
  71. } else {
  72. console.log('ele --> ', ele, ' - ', json[ele]);
  73. console.log('typo del ele --> ', typeof(json[ele]));
  74. console.log(' --------------------- ');
  75. }
  76. }
  77. }
Add Comment
Please, Sign In to add comment