![Level 33](https://cdn.javarush.com/images/article/c909ba7f-a082-4a38-ab7d-ffce86fe2f88/800.jpeg)
-
What is JSON?
JSON (JavaScript Object Notation) is a simple data interchange format based on a subset of the JavaScript programming language.
-
What is the difference between Java and JavaScript?
These are 2 different programming languages, despite the similarity of their names. Both of them have a C-like syntax. The differences are:
- Java implements an OOP approach based on classes, JavaScript - on prototypes;
- Java is statically typed, JavaScript is dynamically typed;
- Java is loaded from compiled bytecode; JavaScript is interpreted directly from the file.
-
What is the difference between JSON and XML?
JSON is a data interchange format.
XML is a markup language (in which you can set the syntax, structure, data types, and generally their model).
Both can be used to transfer data. Naturally, different frameworks are used to work with both standards, the syntax is different.
-
What frameworks for working with JSON do you know?
Level 33 introduced us to the jackson framework. In addition, I will give 3 more, and a link to an article in which they are compared:
- Jackson by FasterXML
- JSON.simple by Yidong Fang
- GSON by Google
- JSONP from Oracle
Comparing Java libraries for working with JSON: JSON.simple, GSON, Jackson and JSONP
-
What frameworks for working with XML do you know?
Since XML is a data representation format, the technologies for working with it are more diverse. Here are the technologies used to serialize Java objects to XML:
- JAXB (included in J in the JDK)
- xstream
Link with a brief overview of various frameworks for working with xml: JAVA + XML
-
What Jackson annotations do you know?
Let's analyze those that were used in the lectures:
- @JsonAutoDetect - placed before the class. Tells Jackson to use the fields of this class when writing or reading. In brackets, you can set the parameter (fieldVisibility = JsonAutoDetect.Visibility.ANY ) to set the visibility of the fields that will be used (only public fields are used by default).
- @JsonIgnore - placed before the field. Tells Jackson to ignore this field when reading/writing.
- @JsonProperty - Placed before a field, getter or setter. Allows you to specify a different field name when serializing.
- @JsonWriteNullProperties - Placed before the class. Object fields that are null will not be ignored.
- @JsonPropertyOrder - Placed before the class. allows you to define the order in which the fields of a java object will be serialized to JSON.
- @JsonDeserialize - Placed before the field. Allows you to define the class into which the JSON object is deserialized. For example, from java, arrays and lists are serialized into arrays, and during deserialization, you can choose what exactly we want to get.
Here is a link to a site with some annotations: Jackson Annotations
-
What JAXB annotations do you know?
I will also analyze only those that were used in the lecture:
- @XmlRootElement - Placed before the class. Indicates that this object may be the topmost element, i.e. all other elements are in it.
- @XmlType - Placed before the class. Adds additional information to the XML schema. You can specify some attributes, such as the order of the elements, name, and so on.
- @XmlElement - Placed before the field. Allows you to set the name of the xml element, the default value, etc.
- @XmlElementWrapper - Placed before a field or getter. Allows you to create a wrapper tag for a group of elements.
- @XmlJavaTypeAdapter - Placed before the class. An auxiliary adapter class is indicated in brackets, which is necessary for marshalling/unmarshalling this class.
- @XmlEnum - Placed before enum. In parentheses, you can specify the type in which enum values will be presented.
- @XmlEnumValue - Preceded by the enum value. Allows you to set a custom value for the given enum value.
@XmlAttribute - Placed before the field. The field will be represented as an XML attribute. Here is a link to a site with some annotations (I apologize for not being able to make a correct translation for annotations, the information is perceived for understanding, but I have absolutely no idea how to say it correctly in Russian): https://jaxb.java.net/tutorial/index .html
-
What is the difference between serialization and deserialization in JSON?
I did not understand the essence of the question. I don't see any point in comparing two mutually inverse processes. Perhaps the comparison of JSON and XML was meant, a link is provided on this topic in the next question.
-
Which is better JSON or XML? Why?
Here is a great article comparing JSON and XML: JSON and XML. What's better?
Perhaps you can not say that something is better. When choosing, you should look at the task itself and what will be more efficient to use. Plus, the choice may depend on the personal preferences of the developer.
-
What is DTO?
DTO (Data Transfer Object) is a design pattern containing data without any logic for working with it. DTOs are commonly used to transfer data between different applications, or between layers within the same application. They can be thought of as a repository of information whose sole purpose is to convey that information to the recipient.
![Level 33](https://cdn.javarush.com/images/article/16fff653-1f7f-4390-a015-f51d735fa574/512.jpeg)
corrected questions #2, #3, according to the remark