Laravel generate forms with JSON - json

Is there a way in Laravel to save JSON code in one table field and when you load that JSON code you get generated form (view) where you can submit data that can be saved in JSON code and then again saved in one table field?

you can use Redis.
$formData = Redis::set('formdata',$json);
$formData = Redis::get('formdata');

Related

how to convert to json from post in Yii2

I want to create json from multiple selection from listbox in yii2 after post i receive following data
categorymodel[0]=11&categorymodel[1]=12&categorymodel[2]=13
how to convert to json data and store in db.
json data like {"11","12","13"}
Once you have the proper array you can use eg:
$retJSON= json_encode($categoryModel);

Save api json to database using laravel

Is it possible to get data from an api url and save it directly to database when working with laravel? the data i get from the url is of the format {"name":"100KVA SUKAM Generator","level":"5.965"}.
Yes, you can create table with json type field (or text) and keep data there:
$table->json('data_from_api');
https://laravel.com/docs/5.2/migrations#writing-migrations
If you want to persist data as usual data, you can use mass assignment. First, convert JSON to an array with [json_decode][1] and save data like that:
$data = json_decode($jsonData, true)
Model::create($data);
Don't forget to add all columns to a $fillable property of a model.

JSON data in spring model

Its a spring based web application. I have a data table in the screen. In my understanding, data table accepts only data in JSON format. so i have a field(String) in my model for holding data table data, the same will be hidden in the screen. Upon listing(form submit not ajax), I would serialize the list to JSON data and keep it in the model. In Javascript, I would populate the data table using the data in the hidden field. It works fine but i have a doubt like whether it is a correct approach ?
I have a export to excel functionality. I would pass the model in the ajax call and get the data from the model and create the XLSX file. Issue is if the data has 3000 records, it works fine but when the record get increases say 4000 the data in the model is coming as null in the handler. Is there any data size limit for the Spring to bind the value to model ?
To your first question, the approach which you are following is correct.
For Export Excel functionality, you can pass the same JSON string which you stored in a hidden variable. And DE-serialize the JSON string to the data. Since JSON is just a string, there is no such limit on Ajax form data

In Talend, how do you keep input values provided to tSoap so that you can use them with the Soap response?

I have a Talend Job that currently does the following:
Input CSV --Main--> tMap --Output--> tSoap --Main--> Output CSV
The input CSV has
ID and TYPE as input columns.
The Map creates a Soap XML (String) message using the ID from the CSV and passes that String to the tSoap component.
The tSoap component fires the web request, which sends the response to the next component. That data is then written to CSV.
The problem is that TYPE from the input CSV is not passed through to amalgamate with the SOAP response data. Only the response data seems accessible.
I've had a look at tBufferInput / tBufferOutput and tFlowToIterate but they seem to work in scenarios where the tSoap component does not depend on an input from the main flow.
Does anyone know which components can be used to achieve the amalgamation?
Thank you
If you output the data you need to reuse to a tHashOutput component you should be able to rejoin your data with the response output from tSoap assuming there's some natural join element from the response.
I solved this in the end by:
Placing between the output from the tMap and the input to the tSoap, a new component - tSetGlobalVar
Inside tSetGlobalVar, you can then create a new row, which maps an input column (Value) to a named variable that you specify as the 'Key'.
E.g. Key = "ID", Value = row11.ID
The output from tSetGlobalVar then goes into the tSoap component.
The output from tSoap goes into a new tMap.
Inside this new tMap is the Body column from the previous tSoap component which maps to an output column. To access the stored "ID" variable for the current flow/iteration, I created a new output column, and instead of mapping any columns from the inputs, used (String)globalMap.get("ID"); which would insert the value back into the flow.

In yii how json formatted inputs are inserted into tables

I am creating project using extjs and yii. My client side design is in extjs-4 and server side design is in yii framework.
Now I am having table Poll with fields as:
pollid
pollQuestion
Isactive
Userid
And Polloption:
pollid
option
Now during creation of new pole,poll creation view form which is designed in extjs will receive inputs and will send this data to server side in json format as-
{
'success':true,
'results':[ {
'pollid' : 1,
'pollQuestion' : 'Which is capital of india',
}
{ options from polloption table in json format
}]
}
So at server side all this values will come in json format. So now in yii i want to insert this received inputs in corresponding poll tables fields.
So how Yii will convert this json formatted inputs and also insert those values into repective fields of poll table. Please help me.
Your question is very vague and general. Here's an overview of what you'll want to do:
submit the data to a Yii controller
If the data is in the body, use PHP's file_get_contents. If you POST or GET it, you can use Yii's CHttpRequest::getParam to read in the raw JSON
use CJSON::decode() to parse the JSON into a PHP array
manipulate the array values, and build a new array
return the data (echo or print it if you just need the raw JSON and don't need a view). You'll probably want to return JSON again to use it in extjs4, so you'll want to use the CJSON::encode() method