1 | <html>
|
2 | <head>
|
3 | <title>Browserify Test</title>
|
4 | <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js"></script>
|
5 | <script type="text/javascript" src="jsonapi-serializer.js"></script>
|
6 | <script>
|
7 | var JSONAPISerializer = require('jsonapi-serializer').Serializer;
|
8 |
|
9 | var dataSet = [{
|
10 | _id: '54735750e16638ba1eee59cb',
|
11 | firstName: 'Sandro',
|
12 | lastName: 'Munda',
|
13 | }, {
|
14 | _id: '5490143e69e49d0c8f9fc6bc',
|
15 | firstName: 'Lawrence',
|
16 | lastName: 'Bennett'
|
17 | }];
|
18 |
|
19 | var json = new JSONAPISerializer('users', {
|
20 | id: '_id',
|
21 | attributes: ['firstName', 'lastName']
|
22 | }).serialize(dataSet);
|
23 |
|
24 | console.log(json);
|
25 | </script>
|
26 | </head>
|
27 | </html>
|