javax.json.stream

Interface JsonParser

    • Method Detail

      • hasNext

        boolean hasNext()
        Returns true if there are more parsing states. This method returns false if the parser reaches the end of the JSON text.
        Returns:
        true if there are more parsing states.
        Throws:
        JsonException - if an i/o error occurs (IOException would be cause of JsonException)
        JsonParsingException - if the parser encounters invalid JSON when advancing to next state.
      • isIntegralNumber

        boolean isIntegralNumber()
        Returns true if the JSON number at the current parser state is a integral number. A BigDecimal may be used to store the value internally and this method semantics are defined using its scale(). If the scale is zero, then it is considered integral type. This integral type information can be used to invoke an appropriate accessor method to obtain a numeric value as in the following example:
         
         JsonParser parser = ...
         if (parser.isIntegralNumber()) {
             parser.getInt();     // or other methods to get integral value
         } else {
             parser.getBigDecimal();
         }
         
         
        Returns:
        true if this number is a integral number, otherwise false
        Throws:
        IllegalStateException - when the parser state is not VALUE_NUMBER
      • getInt

        int getInt()
        Returns a JSON number as an integer. The returned value is equal to new BigDecimal(getString()).intValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. This method should only be called when the parser state is JsonParser.Event.VALUE_NUMBER.
        Returns:
        an integer for a JSON number
        Throws:
        IllegalStateException - when the parser state is not VALUE_NUMBER
        See Also:
        BigDecimal.intValue()
      • getLong

        long getLong()
        Returns a JSON number as a long. The returned value is equal to new BigDecimal(getString()).longValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. This method is only called when the parser state is JsonParser.Event.VALUE_NUMBER.
        Returns:
        a long for a JSON number
        Throws:
        IllegalStateException - when the parser state is not VALUE_NUMBER
        See Also:
        BigDecimal.longValue()
      • getBigDecimal

        BigDecimal getBigDecimal()
        Returns a JSON number as a BigDecimal. The BigDecimal is created using new BigDecimal(getString()). This method should only called when the parser state is JsonParser.Event.VALUE_NUMBER.
        Returns:
        a BigDecimal for a JSON number
        Throws:
        IllegalStateException - when the parser state is not VALUE_NUMBER
      • getLocation

        JsonLocation getLocation()
        Return the location that corresponds to the parser's current state in the JSON input source. The location information is only valid in the current parser state (or until the parser is advanced to a next state).
        Returns:
        a non-null location corresponding to the current parser state in JSON input source
      • close

        void close()
        Closes this parser and frees any resources associated with the parser. This method closes the underlying input source.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Throws:
        JsonException - if an i/o error occurs (IOException would be cause of JsonException)

Traduction non disponible

Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.

Version en cache

21/08/2025 17:18:24 Cette version de la page est en cache (à la date du 21/08/2025 17:18:24) afin d'accélérer le traitement.
Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.

Document créé le 11/06/2005, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/json/stream/JsonParser.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :fr Manuel PHP : https://docs.oracle.com, JsonParser (Java(TM) EE 7 Specification APIs)

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.