Skip to content

Commit

Permalink
Apply toJSON recursively in SemanticQuery.toJSON (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgonggrijp committed Jul 16, 2021
1 parent 26fff8e commit 2f9f39d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion frontend/src/semantic-search/model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { pick, extend, map, mapValues, has, isArray, isObject } from 'lodash';
import {
pick,
extend,
map,
mapValues,
has,
isArray,
isObject ,
isFunction,
} from 'lodash';

import Model from '../core/model';
import Collection from '../core/collection';
Expand All @@ -9,6 +18,7 @@ import { logic, filters } from './dropdown-constants';

function pruneResources(json: any): any {
if (!isObject(json)) return json;
if (isFunction(json['toJSON'])) return pruneResources(json['toJSON']());
if (isArray(json)) return map(json, pruneResources);
if (has(json, '@id')) return pick(json, '@id');
if (has(json, 'id')) return pick(json, 'id');
Expand Down

0 comments on commit 2f9f39d

Please sign in to comment.