JSON Articles

Page 15 of 16

How to deserialize a JSON string using @JsonCreator annotation in Java?

raja
raja
Updated on 17-Feb-2020 1K+ Views

The @JsonProperty annotation can be used to indicate the property name in JSON. This annotation can be used for a constructor or factory method. The @JsonCreator annotation is useful in situations where the @JsonSetter annotation cannot be used. For instance, immutable objects do not have any setter methods, so they need their initial values injected into the constructor.@JsonProperty - ConstructorExampleimport com.fasterxml.jackson.annotation.*; import java.io.IOException; import com.fasterxml.jackson.databind.*; public class JsonCreatorTest1 {    public static void main(String[] args) throws IOException {       ObjectMapper om = new ObjectMapper();       String jsonString = "{\"id\":\"101\", \"fullname\":\"Ravi Chandra\", \"location\":\"Pune\"}";       System.out.println("JSON: " + jsonString);   ...

Read More

How to define alternate names to a field using Jackson in Java?

raja
raja
Updated on 17-Feb-2020 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

Converting OData using SAPUI5 libraries to JSON format

Ali
Ali
Updated on 14-Feb-2020 608 Views

This can be done in multiple ways. One of common approach would be by passing user name/password in URL.$.ajax({    url : "http://user:password@url/SERVICE?$format=json",    type: "GET", //or POST?    dataType: "jsonp",    success: function(){alert("ok")},    error: function(){alert("error")} })

Read More

How to define the naming conventions for JSON field names in Java?

raja
raja
Updated on 14-Feb-2020 2K+ Views

The FieldNamingPolicy can be used to define a few standard naming conventions for JSON field names and it can be used in conjunction with GsonBuilder to configure a Gson instance to properly translate Java field names into the desired JSON field names. We can use the setFieldNamingPolicy() method of GsonBuilder to configure a specific naming policy strategy to an object's field during serialization and deserialization.Gson supports various field naming requirements with following field naming policiesFieldNamingPolicy.IDENTITY: It uses the exact same naming as the Java model when it serializes an object.FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES: It modifies a Java field name from its camel-cased form to a lower case field name where ...

Read More

How to Install Bower on Ubuntu

Sharon Christine
Sharon Christine
Updated on 20-Jan-2020 1K+ Views

Bower is a bundled supervisor for the web and offers a conventional technique for the drawbacks in entrance-finish package management. It basically maintains and monitors all packages and examines new updates. Bower also makes use of a take place file called bower.Json to keep track of applications. This article explains about -“How to install bower on Ubuntu”.To install bower, we require pre-installed Node.js and NPM. To verify the node.js version, use the following command-$ node -vThe sample output should be like this-v6.9.2To verify the NPM version, use the following command$ npm -vThe sample output should be like this-3.10.9If you wants ...

Read More

How To Install and Configure MongoDB on CentOS 7

Sharon Christine
Sharon Christine
Updated on 20-Jan-2020 549 Views

In this article, we will learn how to install and configure the MongoDB on CentOS 7, MongoDB which is an open-source and free database (is a NoSQL database), means it is a document-oriented database, it stores the document which is similar structurally to JSON (in MongoDB it is called as BSON) with high availability, performance and auto scaling. Unlike the RDBMS, it doesn’t need any predefined database schema for adding the data to the database tables. We can alter the schema any point of time without disturbing the existing schema.PrerequisitesCentos 7 installed on the Linux Machine.A user with root user ...

Read More

Generating any custom JSON in ABAP

Manikanth Mani
Manikanth Mani
Updated on 05-Dec-2019 2K+ Views

You can use class ZCL_MDP_JSON Library that can encode/parse any JSON. JSON is supported natively in ABAP by the following features:With the use of JSON-XML- it is known as special XML format that can be used for JSON data to be described using an XML representation. By defining a mapping between ABAP types and JSON. This is used in serializations and deserializations using the identity transformation ID.As you can specify JSON data in different forms as an XML source in the statement CALL TRANSFORMATION and JSON can be specified as a target.Check out the following sample code:Example:DATA text TYPE string VALUE ...

Read More

How to Send and Receive JSON Data to and from the Server

Ayush Gupta
Ayush Gupta
Updated on 27-Nov-2019 3K+ Views

JavaScript can send network requests to the server and load JSON. JS does this using something called AJAX. AJAX stands for Asynchronous JavaScript and XML. JS has an API, fetch, to GET(receive) and POST(send) information to the server.You can use fetch to GET JSON data in the following way −Exampleconst URL = 'https://jsonplaceholder.typicode.com/todos/1' // Send a GET request without any data to the server fetch(URL, {method: "GET"}) // Get the JSON data from the raw response    .then(res => res.json()) // Print the result    .then(console.log)OutputThis will give the output −{    "userId": 1,    "id": 1,    "title": "delectus ...

Read More

How to convert MySQL DATETIME value to JSON format in JavaScript?

AmitDiwan
AmitDiwan
Updated on 07-Oct-2019 710 Views

To convert, use JSON.stringify(). Following is the code to convert MySQL DATETIME value to JSON format in JavaScript − var mySQLDateTime = new Date("Fri Sep 06 2019 22 −54 −48 "); var yearValue = mySQLDateTime.getFullYear(); var dateValue = mySQLDateTime.getDate(); var monthValue=mySQLDateTime.getMonth(); var hour=mySQLDateTime.getHours(); var minutes=mySQLDateTime.getMinutes(); var second=mySQLDateTime.getSeconds(); jsonObject={"year" −yearValue,"month" :monthValue,"DateValue" :dateValue,"Hour" :hour ,"Minutes" :minutes,"Second" :second}; var dateJsonObject = JSON.stringify(jsonObject); document.write(dateJsonObject); The screenshot of the code is as follows −This will produce the following output −{"year" :2019,"month" :8,"DateValue" :6,"Hour" :22,"Minutes" :54,"Second" :48}The snapshot of the output is as follows −

Read More

What are the differences between json and simplejson Python modules?

Rajendra Dharmkar
Rajendra Dharmkar
Updated on 30-Sep-2019 1K+ Views

json is simplejson, added to the stdlib. But since json was added in 2.6, simplejson has the advantage of working on more Python versions (2.4+).simplejson is also updated more frequently than Python. Although they are the same, the version included in the stdlib doesn't include the latest optimizations. So if you need (or want) the latest version, it's best to use simplejson itself, if possible.A good practice, is to use one or the other as a fallback. For example,try: import simplejson as json except ImportError: import json

Read More
Showing 141–150 of 152 articles
Advertisements