Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i get a result without named variable #5

Open
MemoRodMx opened this issue Apr 15, 2020 · 1 comment
Open

How can i get a result without named variable #5

MemoRodMx opened this issue Apr 15, 2020 · 1 comment

Comments

@MemoRodMx
Copy link

Hi, i'm trying to get a serialized result to ommit the name or variable on result.

How can i get the same result like using the $this->set('_serialize', 'varname'); in this plugin?

i want to get a result like this

{ "status": "OK", "result": { "falanu": [ "dhikanu", "tamburo" ] } }

instead of:

{ "status":"OK","result": { "bar": { "falanu": [ "dhikanu", "tamburo" ] } } }

without putting the name variable what i'm using in the response

thank you

@narendravaghela
Copy link
Member

Good question!
As of now, there is no automated solution for this. But you can do that by adding an extra key to your response array. See following example,

public function bar()
{
    $bar = [
        'bar' => [
            'falanu' => [
                'dhikanu',
                'tamburo'
            ]
        ]
    ];
    
    $this->set(compact('bar'));
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants