org.mozilla.javascript.JavaToJSONConverters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rhino Show documentation
Show all versions of rhino Show documentation
Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically
embedded into Java applications to provide scripting to end users.
The newest version!
/* -*- Mode: java; tab-width: 4; indent-tabs-mode: 1; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.javascript;
import java.beans.BeanDescriptor;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.function.UnaryOperator;
/**
* This class provides implementations of converters for Java objects to be used by the
* JSON.stringify method.
*
* JSON.stringify will automatically convert instances of java.util.Map to javascript objects.
* Instances of java.util.Collection and java Arrays will be converted to javascript arrays.
*
*
This is a final effort at conversion for other java objects that appear as values, and may be
* preempted by objects which define a toJSON() method or by a replacer function passed to
* JSON.stringify. The return value will, in turn, be converted according to {@link
* Context#javaToJS} and stringified.
*
* @author Tony Germano
*/
public class JavaToJSONConverters {
private JavaToJSONConverters() {}
/** Convert Object to its toString() value. */
public static final UnaryOperator
© 2015 - 2024 Weber Informatics LLC | Privacy Policy