* detect json better
This commit is contained in:
@@ -40,7 +40,9 @@ function startAdapter(options) {
|
|||||||
const target = {};
|
const target = {};
|
||||||
|
|
||||||
let requestFields = {};
|
let requestFields = {};
|
||||||
if (typeof state.val === 'string' && state.val.startsWith('{') && state.val.endsWith('}')) {
|
if (typeof state.val === 'string') {
|
||||||
|
state.val = state.val.trim();
|
||||||
|
if (state.val.startsWith('{') && state.val.endsWith('}')) {
|
||||||
try {
|
try {
|
||||||
requestFields = JSON.parse(state.val) || {};
|
requestFields = JSON.parse(state.val) || {};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -48,8 +50,9 @@ function startAdapter(options) {
|
|||||||
requestFields = {};
|
requestFields = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If a non-JSON value was set and we only have one relevant field, use this field as value
|
// If a non-JSON value was set, and we only have one relevant field, use this field as value
|
||||||
if (fields && Object.keys(requestFields).length === 0) {
|
if (fields && Object.keys(requestFields).length === 0) {
|
||||||
const fieldList = Object.keys(fields);
|
const fieldList = Object.keys(fields);
|
||||||
if (fieldList.length === 1 && fieldList[0] !== 'entity_id') {
|
if (fieldList.length === 1 && fieldList[0] !== 'entity_id') {
|
||||||
|
|||||||
Reference in New Issue
Block a user