Guest User

Untitled

a guest
Nov 20th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. var posts = require('./posts.json');
  2.  
  3. for(var i=0; i < posts.lenght; i++);
  4. {
  5. console.log(posts[i].Title);
  6. console.log(posts[i].Content);
  7. console.log(posts[i].Author.DisplayName);
  8. console.log(posts.lenght);
  9. }
  10.  
  11. [
  12. {
  13. "PostID" : 1,
  14. "Title" : "My first post",
  15. "Content" : "Some content",
  16. "Comments" : [
  17. {
  18. "CommentID" : 1,
  19. "Content" : "Commenting on your first post"
  20. },
  21. {
  22. "CommentID" : 2,
  23. "Content" : "Also on your first post"
  24. }
  25. ],
  26. "Author" : {
  27. "UserId" : 1,
  28. "DisplayName" : "poo3"
  29. }
  30. },
  31. {
  32. "PostID" : 2,
  33. "Title" : "My second post",
  34. "Content" : "Some content",
  35. "Comments" : [
  36. {
  37. "CommentID" : 3,
  38. "Content" : "Commenting on your second post"
  39. }
  40. ] ,
  41. "Author" : {
  42. "UserId" : 1,
  43. "DisplayName" : "poo2"
  44. }
  45. },
  46. {
  47. "PostID" : 3,
  48. "Title" : "My third post",
  49. "Content" : "Some content" ,
  50. "Author" : {
  51. "UserId" : 2,
  52. "DisplayName" : "poo1"
  53. }
  54. }
  55. ]
Add Comment
Please, Sign In to add comment