public static void deserializeToField(final Object containingObject, final String fieldName, final String json,
            final ClassFieldCache classFieldCache) throws IllegalArgumentException {
        if (containingObject == null) {
            throw new IllegalArgumentException("Cannot deserialize to a field of a null object");
        }

        // Parse the JSON
        Object parsedJSON;
        try {
            parsedJSON = JSONParser.parseJSON(json);
        } catch (final ParseException e) {
            throw new IllegalArgumentException("Could not parse JSON", e);
        }

        // Create a JSONObject with one field of the requested name, and deserialize that into the requested object
        final JSONObject wrapperJsonObj = new JSONObject(1);
        wrapperJsonObj.items.add(new SimpleEntry<>(fieldName, parsedJSON));

        // Populate the object field
        // (no need to call getInitialIdToObjectMap(), since toplevel object is a wrapper, which doesn't have an id)
        final List<Runnable> collectionElementAdders = new ArrayList<>();
        populateObjectFromJsonObject(containingObject, containingObject.getClass(), wrapperJsonObj, classFieldCache,
                new HashMap<CharSequence, Object>(), collectionElementAdders);
        for (final Runnable runnable : collectionElementAdders) {
            runnable.run();
        }
    }
public static void deserializeToField ( final Object containingObject , final String fieldName , final String json , final ClassFieldCache classFieldCache ) throws IllegalArgumentException { if ( containingObject == null ) { throw new IllegalArgumentException ( "Cannot deserialize to a field of a null object" ) ; } Object parsedJSON ; try { parsedJSON = JSONParser . parseJSON ( json ) ; } catch ( final ParseException e ) { throw new IllegalArgumentException ( "Could not parse JSON" , e ) ; } final JSONObject wrapperJsonObj = new JSONObject ( 1 ) ; wrapperJsonObj . items . add ( new SimpleEntry < > ( fieldName , parsedJSON ) ) ; final List < Runnable > collectionElementAdders = new ArrayList < > ( ) ; populateObjectFromJsonObject ( containingObject , containingObject . getClass ( ) , wrapperJsonObj , classFieldCache , new HashMap < CharSequence , Object > ( ) , collectionElementAdders ) ; for ( final Runnable runnable : collectionElementAdders ) { runnable . run ( ) ; } }
Deserialize JSON to a new object graph, with the root object of the specified expected type, and store the
root object in the named field of the given containing object. Works for generic types, since it is possible
to obtain the generic type of a field.

@param containingObject
The object containing the named field to deserialize the object graph into.
@param fieldName
The name of the field to set with the result.
@param json
the JSON string to deserialize.
@param classFieldCache
The class field cache. Reusing this cache will increase the speed if many JSON documents of the
same type need to be parsed.
@throws IllegalArgumentException
If anything goes wrong during deserialization.