Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const util = require('util')
- norm_widget_1 = {
- 'foo': 1,
- 'bar': 'baz',
- '_jv': {
- 'type': 'widget',
- 'id': '1',
- 'relationships': {
- 'widgets': {
- 'data': {
- 'type': 'widget',
- 'id': '2'
- },
- 'links': {
- 'related': '/widget/1/widgets'
- }
- }
- }
- }
- }
- norm_widget_2 = {
- 'foo': 2,
- '_jv': {
- 'type': 'widget',
- 'id': '2',
- 'relationships': {
- 'widgets': {
- 'data': [
- {
- 'type': 'widget',
- 'id': '1'
- },
- {
- 'type': 'widget',
- 'id': '3'
- }
- ]
- }
- }
- }
- }
- norm_widget_1_rels = JSON.parse(JSON.stringify(norm_widget_1))
- norm_widget_1_rels['_jv']['rels'] = { 'widgets': norm_widget_2 }
- console.log(util.inspect(norm_widget_1_rels, { showHidden: false, depth: null }))
- // Output:
- // { foo: 1,
- // bar: 'baz',
- // _jv:
- // { type: 'widget',
- // id: '1',
- // relationships:
- // { widgets:
- // { data: { type: 'widget', id: '2' },
- // links: { related: '/widget/1/widgets' } } },
- // rels:
- // { widgets:
- // { foo: 2,
- // _jv:
- // { type: 'widget',
- // id: '2',
- // relationships:
- // { widgets:
- // { data: [ { type: 'widget', id: '1' }, { type: 'widget', id: '3' } ] } } } } } } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement