Class BeanMapLoader

java.lang.Object
org.apache.juneau.marshall.BeanMapLoader

public final class BeanMapLoader extends Object
Marshalling-side helper for loading BeanMap contents from JSON text or a reader/parser pair.
Example:

// Populate a bean map from a JSON string. BeanMap<Person> m = bc.newBeanMap(Person.class); BeanMapLoader.load(m, "{name:'John',age:21}");

  • Method Details

    • load

      public static <T> BeanMap<T> load(BeanMap<T> m, String input) throws ParseException
      Populates the supplied BeanMap with the contents of the JSON text in input.

      Equivalent to the legacy BeanMap.load(String) method.

      Type Parameters:
      T - The bean type.
      Parameters:
      m - The bean map to populate. Must not be null.
      input - The text that will get parsed into a map and then added to m. Can be null (nothing is added).
      Returns:
      The supplied bean map for fluent chaining.
      Throws:
      ParseException - Malformed input encountered.
    • load

      public static <T> BeanMap<T> load(BeanMap<T> m, Reader r, ReaderParser p) throws ParseException
      Populates the supplied BeanMap with the contents of the reader using the specified ReaderParser.

      Equivalent to the legacy BeanMap.load(Reader, ReaderParser) method.

      Type Parameters:
      T - The bean type.
      Parameters:
      m - The bean map to populate. Must not be null.
      r - The reader containing serialized text. Can be null (nothing is added).
      p - The parser to use to parse the text.
      Returns:
      The supplied bean map for fluent chaining.
      Throws:
      ParseException - Malformed input encountered.