Git Product home page Git Product logo

Comments (2)

Akdr avatar Akdr commented on August 26, 2024 1

Im having the same problem.

Any ideas on this one?

class C\A\MicroService
public function handle(string $json) : array
    {
        $jsonq = new Jsonq();
        $jsonq->json($json);

        $matchLevel = $jsonq->from('matchLevel')->get();

        if($matchLevel != 'Street number'){
            throw new \Exception('To low matchLevel, level is ' . $matchLevel );
        }

        $res = $jsonq->from('products')->get();
        return $res;
    }
PHP Warning:  array_key_exists() expects parameter 2 to be array, string given in /var/app/microservices/vendor/nahid/jsonq/src/JsonQueriable.php on line 334
PHP Stack trace:
PHP   1. {main}() /var/app/microservices/test/index.php:0
PHP   2. C\A\MicroService->handle() /var/app/microservices/test/index.php:23
PHP   3. Nahid\JsonQ\Jsonq->get() /var/app/microservices/src/single.php:48
PHP   4. Nahid\JsonQ\Jsonq->prepare() /var/app/microservices/vendor/nahid/jsonq/src/Jsonq.php:120
PHP   5. Nahid\JsonQ\Jsonq->getData() /var/app/microservices/vendor/nahid/jsonq/src/JsonQueriable.php:135
PHP   6. Nahid\JsonQ\Jsonq->getFromNested() /var/app/microservices/vendor/nahid/jsonq/src/JsonQueriable.php:359
PHP   7. array_key_exists() /var/app/microservices/vendor/nahid/jsonq/src/JsonQueriable.php:334

EDIT:
Made a workaround that "works".

// class C\A\MicroService
public function handle(string $json) : array
{
        $jsonq = new Jsonq();
        $jsonq->json($json);

        // Repeated the object, clone does not work
        $jsonq2 = new Jsonq();
        // Run json method again. 
        $jsonq2->json($json);

        // Use the second json here
        $matchLevel = $jsonq2->from('matchLevel')->get();

        if($matchLevel != 'Street number'){
            throw new \Exception('To low matchLevel, level is ' . $matchLevel );
        }

        //Use the first json here
        $res = $jsonq->from('products')->get();
        return $res;
}

from jsonq.

nahid avatar nahid commented on August 26, 2024

This issue has been resolved.

https://github.com/nahid/jsonq/releases/tag/v5.2.4

from jsonq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.