import { SearchSourceFields } from './types' ; import { InvalidJSONProperty } from '../../../../opensearch_dashboards_utils/common' ; export const parseSearchSourceJSON = ( searchSourceJSON ) => { let searchSourceValues ; try { searchSourceValues = JSON . parse ( searchSourceJSON ) ; } catch ( e ) { throw new InvalidJSONProperty ( `Invalid JSON in search source. ${ e . message } JSON: ${ searchSourceJSON }` ) ; } if ( ! searchSourceValues || typeof searchSourceValues !== 'object' ) { throw new InvalidJSONProperty ( 'Invalid JSON in search source.' ) ; } return searchSourceValues ; } ;