1.0.4 • Published 6 years ago

angular-json-sample v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Angular & NodeJS JSON Sample Data Generator

Angular-json-sample is a simple & handy package, Which generate a sample json data for angular & node. You can easily generate different types of json data by following the below steps.

Step 1:

Instalitions

$ npm i angular-json-sample

Step 2:

Importing to component

import { jsonSample } from 'json-sample-data';

Step 3:

Usage

let posts = jsonSample("posts");
console.log(posts);

Usage in NodeJS

var JS = require("angular-json-sample")
var posts = JS.jsonSample()
console.log(posts);

The above code snippet will return the following array of post objects.

[
  {
    "userId": 1,
    "id": 1,
    "title": "sunt aut facere repellat provident",
    "body": "quia et suscipit suscipit recusandae ..."
  },
  {
    "userId": 1,
    "id": 2,
    "title": "qui est esse",
    "body": "est rerum tempore vitae ..."
  },
  ...
]

Following are the list of possible parameters and their results.

Getting comment objects

var comments = jsonSample("comments");
console.log(comments);

Result

[
  {
    "postId": 1,
    "id": 1,
    "name": "id labore ex et quam laborum",
    "email": "Eliseo@gardner.biz",
    "body": "laudantium enim quasi est quidem magnam ..."
  },
  {
    "postId": 1,
    "id": 2,
    "name": "quo vero reiciendis velit similique earum",
    "email": "Jayne_Kuhic@sydney.com",
    "body": "est natus enim nihil est dolore omnis ..."
  },
  ...
]

Getting albums objects

var albums = jsonSample("albums");
console.log(albums);

Result

[
  {
    "userId": 1,
    "id": 1,
    "title": "quidem molestiae enim"
  },
  {
    "userId": 1,
    "id": 2,
    "title": "sunt qui excepturi placeat culpa"
  },
  ...
]

Getting photos objects

var photos = jsonSample("photos");
console.log(photos);

Result

[
  {
    "albumId": 1,
    "id": 1,
    "title": "accusamus beatae ad facilis cum similique qui sunt",
    "url": "http://placehold.it/600/92c952",
    "thumbnailUrl": "http://placehold.it/150/92c952"
  },
  {
    "albumId": 1,
    "id": 2,
    "title": "reprehenderit est deserunt velit ipsam",
    "url": "http://placehold.it/600/771796",
    "thumbnailUrl": "http://placehold.it/150/771796"
  },
  ...
]

Getting todos objects

var todos = jsonSample("todos");
console.log(todos);

Result

[
  {
    "userId": 1,
    "id": 1,
    "title": "delectus aut autem",
    "completed": false
  },
  {
    "userId": 1,
    "id": 2,
    "title": "quis ut nam facilis et officia qui",
    "completed": false
  },
  ...
]

Getting users objects

var users = jsonSample("users");
console.log(users);

Result

[
  {
    "id": 1,
    "name": "Leanne Graham",
    "username": "Bret",
    "email": "Sincere@april.biz",
    "address": {
      "street": "Kulas Light",
      "suite": "Apt. 556",
      "city": "Gwenborough",
      "zipcode": "92998-3874",
      "geo": {
        "lat": "-37.3159",
        "lng": "81.1496"
      }
    },
    "phone": "1-770-736-8031 x56442",
    "website": "hildegard.org",
    "company": {
      "name": "Romaguera-Crona",
      "catchPhrase": "Multi-layered client-server neural-net",
      "bs": "harness real-time e-markets"
    }
  },
  {
    "id": 2,
    "name": "Ervin Howell",
    "username": "Antonette",
    "email": "Shanna@melissa.tv",
    "address": {
      "street": "Victor Plains",
      "suite": "Suite 879",
      "city": "Wisokyburgh",
      "zipcode": "90566-7771",
      "geo": {
        "lat": "-43.9509",
        "lng": "-34.4618"
      }
    },
    "phone": "010-692-6593 x09125",
    "website": "anastasia.net",
    "company": {
      "name": "Deckow-Crist",
      "catchPhrase": "Proactive didactic contingency",
      "bs": "synergize scalable supply-chains"
    }
  },
  ...
]

Please feel free to contact if you have any problem while using this package, I always like to help and solve the problems of other people.

Email: asfand.dev@gmail.com Website: asfand.info

1.0.4

6 years ago

1.0.2

6 years ago

1.0.1

7 years ago

1.0.0

7 years ago