Define Alternate Names to a Field Using Jackson in Java

raja
Updated on 17-Feb-2020 07:20:53

5K+ Views

The @JsonAlias annotation can define one or more alternate names for the attributes accepted during the deserialization, setting the JSON data to a Java object. But when serializing, i.e. getting JSON from a Java object, only the actual logical property name is used instead of the alias.Syntax@Target(value={ANNOTATION_TYPE, FIELD, METHOD, PARAMETER}) @Retention(value=RUNTIME) public @interface JsonAliasExampleimport com.fasterxml.jackson.annotation.*; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import java.io.*; public class ObjectToJsonTest {    public static void main(String[] args) throws JsonProcessingException {       ObjectMapper mapper = new ObjectMapper();       Technology tech = new Technology("Java", "Oracle");       Employee emp = new Employee(110, "Raja", tech);   ... Read More

Difference Between jQuery load and jQuery get Methods

Ricky Barnes
Updated on 17-Feb-2020 07:17:43

635 Views

jQuery load() methodThe load( url, data, callback ) method loads data from the server and places the returned HTML into the matched element.Here is the description of all the parameters used by this method −url − A string containing the URL to which the request is sent.data − This optional parameter represents a map of data that is sent with the request.callback − This optional parameter represents a function that is executed if the request succeedsAssuming we have following HTML content in result.html file:THIS IS RESULT...ExampleThe following is the code snippet showing the usage of this method.            ... Read More

Difference Between jQuery POST and GET Methods

Ricky Barnes
Updated on 17-Feb-2020 07:13:59

294 Views

jQuery post() methodThe jQuery.post( url, [data], [callback], [type] ) method loads a page from the server using a POST HTTP request.Assuming we have following PHP content in result.php file, ExampleThe following is the code snippet showing the usage of this method −                                 $(document).ready(function() {                         $("#driver").click(function(event){                                $.post(                   "result.php", ... Read More

What does jQuery serialize Method Do in jQuery

Ricky Barnes
Updated on 17-Feb-2020 07:07:40

230 Views

The serialize() method serializes a set of input elements into a string of data. Let’s say we have the following PHP content in serialize.php file −ExampleThe following is the code snippet showing the usage of this method −                                 $(document).ready(function() {                         $("#driver").click(function(event){                                $.post(                   "/jquery/serialize.php",                   $("#testform").serialize(),                                           function(data) {                      $('#stage1').html(data);                   }                    );                                    var str = $("#testform").serialize();                $("#stage2").text(str);             });                          });                             Click on the button to load result.html file:                        STAGE - 1                                    STAGE - 2                                                                      Name:                                                                        Age:                                                                                        Sex:                                                       Male                   Female                                                                                                                                                                                          

Put a Complete HTML Page in a Div Using jQuery

Ricky Barnes
Updated on 17-Feb-2020 07:06:12

647 Views

To put complete HTML page in a div using jQuery, use the load() method. Firstly, add the web page you want to add.Here’s the code for new.html −     Heading 1 Demo text ExampleNow, the code for the HTML file which adds the above page, $(document).ready(function(){        $('#myid').load("new.html"); });

Use jQuery getJSON to Load JSON File in jQuery

Ricky Barnes
Updated on 17-Feb-2020 07:04:28

1K+ Views

The jQuery.getJSON( url, [data], [callback] ) method loads JSON data from the server using a GET HTTP request.Assuming we have the following JSON content in result.json file −{ "name": "Amy", "age" : "24", "sex": "female" }ExampleThe following is the code snippet showing the usage of this method −                                 $(document).ready(function() {                         $("#driver").click(function(event){                $.getJSON('result.json', function(jd) {                   $('#stage').html(' Name: ' + jd.name + '');                   $('#stage').append('Age : ' + jd.age+ '');                   $('#stage').append(' Sex: ' + jd.sex+ '');                });             });                          });                             Click on the button to load result.html file:                        STAGE                                

Use jQuery getScript Method to Load External JS Files

Ricky Barnes
Updated on 17-Feb-2020 07:03:25

3K+ Views

The jQuery.getScript( url, [callback] ) method loads and executes a JavaScript file using an HTTP GET request.Here is the description of all the parameters used by this method −url − A string containing the URL to which the request is sentcallback − This optional parameter represents a function to be executed whenever the data is loaded successfully.Assuming we have following JavaScript content in result.js file −function CheckJS(){    alert("This is JavaScript"); }ExampleThe following is the code snippet showing the usage of this method −                              $(document).ready(function() {   ... Read More

Use jQuery serializeArray Method to Serialize Data

Ricky Barnes
Updated on 17-Feb-2020 07:02:06

639 Views

The serializeArray( ) method serializes all forms and form elements like the .serialize() method but returns a JSON data structure for you to work with.Assuming we have following PHP content in serialize.php file −ExampleThe following is an example showing the usage of this method −Live Demo           The jQuery Example                              $(document).ready(function() {                         $("#driver").click(function(event){                             ... Read More

Access Values Created by serializeArray in jQuery

Ricky Barnes
Updated on 17-Feb-2020 07:00:20

662 Views

To access values creates by serializeArray, use the serializeArray( ) method. The serializeArray( ) method serializes all forms and form elements like the .serialize() method but returns a JSON data structure for you to work with.Let’s say we have the following PHP content in serialize.php file −The following is an example showing the usage of this method −ExampleLive Demo           The jQuery Example                              $(document).ready(function() {                         $("#driver").click(function(event){     ... Read More

Get Value from Serialized Array in jQuery

Ricky Barnes
Updated on 17-Feb-2020 06:56:19

4K+ Views

To get value from serialized array, use th serializeArray( ) method. The serializeArray( ) method serializes all forms and form elements like the .serialize() method but returns a JSON data structure for you to work with.Let’s say we have the following PHP content in serialize.php file −The following is an example showing the usage of this method:ExampleLive Demo           The jQuery Example                              $(document).ready(function() {                         $("#driver").click(function(event){     ... Read More

Advertisements