Level 41

Level 33

Published in the Random EN group
Questions/additions/criticism are welcome. Level 33
  1. What is JSON?

    JSON (JavaScript Object Notation) is a simple data interchange format based on a subset of the JavaScript programming language.

  2. 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.

    Your text to link...

  3. 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.

  4. 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:

    1. Jackson by FasterXML
    2. JSON.simple by Yidong Fang
    3. GSON by Google
    4. JSONP from Oracle

    Comparing Java libraries for working with JSON: JSON.simple, GSON, Jackson and JSONP

  5. 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:

    1. JAXB (included in J in the JDK)
    2. xstream

    Link with a brief overview of various frameworks for working with xml: JAVA + XML

  6. 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

  7. 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.
    • @XmlAttribute - Placed before the field. The field will be represented as an XML attribute.
    • @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.

    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): .html

  8. 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.

  9. 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.

  10. 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
Updated on 10.11.2016 at 15.50

corrected questions #2, #3, according to the remark