I have a HTML form which I want to turn into a JSON to send to a a server. It seems like having a simple mechanism where a the values of a form could be turned into a JSON string would be soemthing that might be in the library, so is there a library to do this?
If you created the form using the Input library, then merge the signals of the form Inputs into one record signal, which you can convert to JSON with the JavaScript.Experimental API.
If you created the form in HTML/JS, there is no need to delegate this task to Elm, just transform the form's DOM to your desired object representation using JavaScript.
Related
'PowerApp->Content'.Run(JSON(DetailForm1,JSONFormat.IncludeBinaryData)
I am trying to put this action on a button but im getting an error
the json function cannot serialise objects of type control
Is there any workaround to this? I want to send data to create a new excel file.
You probably don't want to serialize the form itself, but the updates that the form would send to the data source associated with it. If that's the case, then you can use this expression:
'PowerApp->Content'.Run(JSON(DetailForm1.Updates))
Notice that the edit form control has an Updates property, while the display form control does not. Not sure which type your 'DetailForm1' is, but if it is a display form, you can replace it with an edit form, and set its DefaultMode property to FormMode.View, and that will make it essentially a display form.
I am new to Django. I have a few independent dropdown boxes. Now I have to get data from the backend in JSON and parse it for each dropdown boxes. How do I do this? How do I bring JSON via URL? how should I make use of Ajax methods here?
Basically, I want to use Ajax method calls and JSON bind data to ui.
I want to insert data into a mongodb collection from a HTML Form and I want it to have a specific structure. e.g.
{name:{first_name:"", last_name:""}, address:{street:"",
post_code:""}}
In a normal form submission the data doesn't seem to have structure. Any ideas?
Thanks!
HTML cannot insert into MongoDB directly, you need an application layer, if your application is based on java, you can map the form values into an object of your choice and then save that object in MongoDB.
If you are using nodeJS, it is even easier where you can form the said structure on the frontend and make an ajax call to node server and it can save the passed request as it is into MongoDB.
If you must use HTML form, I think you will have to do the hard work of parsing the HTML data to object of desired structure.
I am working on play framework with SCALA as backend.
Json data is given to the front end from the controller.
I want to add HTML as value of some fields of json.
This HTML will be kept as a template and data will be added in this template at run time.
I think i should put unique names in the HTML template and then these names will be replaced by the data which i want to add at run time. Ultimately, this HTML will be added in the json response.
Is my approach right? If not, what is the best approach to add data in an HTML template,add this template in json response and send this combined response to the front-end for further use?
Is it a good practice to use string replacement to add data in an HTML template?
I think as long as you use Play, you can put your HTML templates into app/views package. Let's say you call your template mytemplate.scala.html
You can parameterize this view as any Play view.
In the place in your code where you generate your JSON response you can then call mytemplate(parameters) to get html generated, Play will do all the work here for you. Then using play.api.libs.json.JSON object's methods and related facilities you can convert this html to JSON.
So in your controller's code you will have something like Ok(JSON.toJson(mytemplate(parameters)))
This is of course a sketch, so you will need to elaborate and try.
I am trying to generate a report page in my APEX application, using the data obtained from a REST service response.
I added a new RESTful webservice reference and sepecified a JSON output.
Then I've generated a query/report page, but this is what's being currently displayed:
Instead I want the report to display the contents of data field on the JSON response (A single row with various columns and values)
Is there any straight forward way to show each response element and field on its row and column instead of a single column and row with the whole response, like there is with XML RESTful responses?
Consider whether another output type may be more handy. If you're putting out JSON and expect to handle it in PLSQL, then you do need to realize that PLSQL does not handle that natively.
Want to handle the rest response as json in plsql? Then look into some PLSQL libraries/projects that may do this:
http://reseau.erasme.org/pl-sql-library-for-JSON?lang=en
http://sourceforge.net/projects/pljson/
Then print out the returned HTML through HTP.P calls.
Though honestly, if you want to stick with plsql you would be much better off using XML as a return type, since you can then use all the xml goodies in the database. Though simply spitting out some html structure may not be quite too interesting (but I digress).
Or call the rest service through an ajax call from javascript, and handle the object there. After all, JSON is Javascript Object Notation and should be perfect for javascript, right? Then simply inject your html somewhere in the document. Ideally you would set up a region as a container for this.