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

Using json middleware and mapping #987

Open
informsnca opened this issue Aug 30, 2023 · 3 comments
Open

Using json middleware and mapping #987

informsnca opened this issue Aug 30, 2023 · 3 comments
Assignees

Comments

@informsnca
Copy link

Hi there.

I am trying to rename columns and get some columns to output json, but i cant get it to work.

This is my configs:
'tables' => 'e506b823df49_survey_513632,demo',
'middlewares' => 'cors,errors,basicAuth,json',
'controllers' => 'records,geojson,openapi,status',
'customControllers' => '',
'customOpenApiBuilders' => '',
'cacheType' => 'TempFile',
'cachePath' => '',
'cacheTime' => 10,
'debug' => false,
'basePath' => '',
'openApiBase' => '{"info":{"title":"PHP-CRUD-API","version":"1.0.0"}}',
'json.tables' => 'demo',
'json.columns' => 'two',
'mapping' => 'demo2=demo3,wp_posts.one=demo2.ones',

And this is my json structure:
{"records":[{"one":"{"depth": false, "model": "TRX-120", "width": 100, "height": null}","two":"{"depth": false, "model": "TRX-120", "width": 100, "height": null}","3":0,"4":null,"5":null,"key":0}]}

What am i doing wrong?

@mevdschee mevdschee self-assigned this Sep 1, 2023
@mevdschee
Copy link
Owner

mevdschee commented Sep 1, 2023

What is the request you are doing and what is the expected output? Also, what is the table structure you are using (SQL create statement)?

@informsnca
Copy link
Author

I am using SQL. I am trying both to rename the table columns with this line: 'mapping' => 'demo2=demo3,wp_posts.one=demo2.ones',
And i am trying to use the JSON middleware to get this structure turned into propper json: {"depth": false, "model": "TRX-120", "width": 100, "height": null}

Regarding the JSON middleware, i have both tried to make the fields a JSON field and a text field in the database :)

@mevdschee
Copy link
Owner

'mapping' => 'demo2=demo3,wp_posts.one=demo2.ones',

It seems you are renaming the table twice. I think that that is not supported.

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

No branches or pull requests

2 participants