php-crud-api
php-crud-api copied to clipboard
Using json middleware and mapping
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?
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)?
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 :)
'mapping' => 'demo2=demo3,wp_posts.one=demo2.ones',
It seems you are renaming the table twice. I think that that is not supported.