Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var posts = require('./posts.json');
- for(var i=0; i < posts.lenght; i++);
- {
- console.log(posts[i].Title);
- console.log(posts[i].Content);
- console.log(posts[i].Author.DisplayName);
- console.log(posts.lenght);
- }
- [
- {
- "PostID" : 1,
- "Title" : "My first post",
- "Content" : "Some content",
- "Comments" : [
- {
- "CommentID" : 1,
- "Content" : "Commenting on your first post"
- },
- {
- "CommentID" : 2,
- "Content" : "Also on your first post"
- }
- ],
- "Author" : {
- "UserId" : 1,
- "DisplayName" : "poo3"
- }
- },
- {
- "PostID" : 2,
- "Title" : "My second post",
- "Content" : "Some content",
- "Comments" : [
- {
- "CommentID" : 3,
- "Content" : "Commenting on your second post"
- }
- ] ,
- "Author" : {
- "UserId" : 1,
- "DisplayName" : "poo2"
- }
- },
- {
- "PostID" : 3,
- "Title" : "My third post",
- "Content" : "Some content" ,
- "Author" : {
- "UserId" : 2,
- "DisplayName" : "poo1"
- }
- }
- ]
Add Comment
Please, Sign In to add comment