When trying to parse JSON with nested arrays, the context works as designed. Ie.

Context: $.results.*

{
    results: [
        {
            key: 'value',
        }
    ]
}

But I get an error when I attempt to parse a flat array with an empty context. Ie.

Context: $.*

{
    key: 'value',
}

which results in the following error:

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=59&op=do StatusText: Service unavailable (with message) ResponseText: Recoverable fatal error: Argument 1 passed to FeedsJSONPathParser::invokeHook() must be of the type array, boolean given, called in /feeds_jsonpath_parser/FeedsJSONPathParser.inc on line 80 and defined in FeedsJSONPathParser->invokeHook() (line 433 of /feeds_jsonpath_parser/FeedsJSONPathParser.inc).

It seems that the parser expects a context as an array.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

firewaller created an issue. See original summary.

firewaller’s picture

Added context array check to prevent errors

firewaller’s picture

The above patch causes an error for all imports with multidimensional contexts.

Attached is an updated patch that checks for flat contexts.

markchitty’s picture

#3 solved the issue on my setup, existing multidimensional imports still worked too! thanks.

ameymudras’s picture

FileSize
627 bytes

I also faced the same issue but the above patch didn't. The problem is happening because the invokeHook method assumes its first argument to be a array but when there is a flat array or some in consistency in the JSON it doesn't work as expected. The best solution according to me would be dropping the type casting. Providing a patch for the same.

ameymudras’s picture

Status: Active » Needs review