org.apache.avro

## Class JsonProperties

- java.lang.Object
- - org.apache.avro.JsonProperties

- Direct Known Subclasses:
    Protocol, Protocol.Message, Schema, Schema.Field

      public abstract class JsonProperties
      extends Object

  Base class for objects that have JSON-valued properties. Avro and JSON values are represented in Java using the following mapping:

  | Avro type | JSON type | Java type
  `null` | `null` | `NULL_VALUE`
  `boolean` | Boolean | `boolean`
  `int` | Number | `int`
  `long` | Number | `long`
  `float` | Number | `float`
  `double` | Number | `double`
  `bytes` | String | `byte[]`
  `string` | String | `String`
  `record` | Object | `Map`
  `enum` | String | `String`
  `array` | Array | `Collection`
  `map` | Object | `Map`
  `fixed` | String | `byte[]`

  See Also:
    `Json`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `JsonProperties.Null`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static JsonProperties.Null` | `NULL_VALUE` A value representing a JSON `null`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAllProps(JsonProperties properties)` Adds all the props from the specified json properties.
    `void` | `addProp(String name, Object value)`
    `void` | `addProp(String name, String value)` Adds a property with the given name `name` and value `value`.
    `Object` | `getObjectProp(String name)` Returns the value of the named property in this schema.
    `Map<String,Object>` | `getObjectProps()` Return the defined properties as an unmodifiable Map.
    `String` | `getProp(String name)` Returns the value of the named, string-valued property in this schema.
    `boolean` | `hasProps()`
    `void` | `putAll(JsonProperties np)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### NULL_VALUE

          public static final JsonProperties.Null NULL_VALUE

      A value representing a JSON `null`.

  - ### Method Detail

    - #### getProp

          public String getProp(String name)

      Returns the value of the named, string-valued property in this schema. Returns `null` if there is no string-valued property with that name.

    - #### getObjectProp

          public Object getObjectProp(String name)

      Returns the value of the named property in this schema. Returns `null` if there is no property with that name.

    - #### addProp

          public void addProp(String name,
                              String value)

      Adds a property with the given name `name` and value `value`. Neither `name` nor `value` can be `null`. It is illegal to add a property if another with the same name but different value already exists in this schema.
      Parameters:
        `name` - The name of the property to add
        `value` - The value for the property to add

    - #### addProp

          public void addProp(String name,
                              Object value)

    - #### putAll

          public void putAll(JsonProperties np)

    - #### addAllProps

          public void addAllProps(JsonProperties properties)

      Adds all the props from the specified json properties.
      See Also:
        `getObjectProps()`

    - #### getObjectProps

          public Map<String,Object> getObjectProps()

      Return the defined properties as an unmodifiable Map.

    - #### hasProps

          public boolean hasProps()

Copyright © 2009–2024 The Apache Software Foundation. All rights reserved.