anchor.diff:  parse_bytes(_, _) ->
     erlang:error(wrong_bytes_string).
   
  -parse_record({struct, Attrs}, Type, ExtractFun) ->
  -  Fields = convert_attrs_to_record_fields(Attrs, Type, ExtractFun),
  -  avro_record:new(Type, Fields);
  -parse_record(_, _, _) ->
  +parse_record({struct, Attrs}, Type, ExtractFun, IsWrapped) ->
  +  Fields = convert_attrs_to_record_fields(Attrs, Type, ExtractFun, IsWrapped),
  +  case IsWrapped of
  +    true ->
  +      avro_record:new(Type, Fields);
  +    false ->
  +      Name = avro:get_type_fullname(Type),
  +      {Name, Fields}
  +  end;
  +parse_record(_, _, _, _) ->
     erlang:error(wrong_record_value).
   
  -convert_attrs_to_record_fields(Attrs, Type, ExtractFun) ->
  +convert_attrs_to_record_fields(Attrs, Type, ExtractFun, IsWrapped) ->
     lists:map(
       fun({FieldNameBin, Value}) ->
           FieldName = binary_to_list(FieldNameBin),
           FieldType = avro_record:get_field_type(FieldName, Type),
  -        {FieldName, parse_value(Value, FieldType, ExtractFun)}
  +        {FieldName, parse(Value, FieldType, ExtractFun, IsWrapped)}
       end,
       Attrs).
   
  -parse_array(V, Type, ExtractFun) when is_list(V) ->
  +parse_array(V, Type, ExtractFun, IsWrapped) when is_list(V) ->
     ItemsType = avro_array:get_items_type(Type),
     Items = lists:map(
               fun(Item) ->
  -                parse_value(Item, ItemsType, ExtractFun)
  +                parse(Item, ItemsType, ExtractFun, IsWrapped)
               end,
               V),
  -  %% Here we can use direct version of new because we casted all items
  -  %% to the array type before
  -  avro_array:new_direct(Type, Items);
  -parse_array(_, _, _) ->
  +  case IsWrapped of
  +    true ->
  +      %% Here we can use direct version of new because we casted all items
  +      %% to the array type before
  +      avro_array:new_direct(Type, Items);
  +    false ->
  +      Items
  +  end;
  +parse_array(_, _, _, _) ->
     erlang:error(wrong_array_value).
   
  -parse_map({struct, Attrs}, Type, ExtractFun) ->
  +parse_map({struct, Attrs}, Type, ExtractFun, IsWrapped) ->
     ItemsType = avro_map:get_items_type(Type),
     D = lists:foldl(
           fun({KeyBin, Value}, D) ->
               dict:store(binary_to_list(KeyBin),
  -                       parse_value(Value, ItemsType, ExtractFun),
  +                       parse(Value, ItemsType, ExtractFun, IsWrapped),
                          D)
           end,
           dict:new(),
           Attrs),
  -  avro_map:new(Type, D).
  -
  -parse_union(null = Value, Type, ExtractFun) ->
  +  case IsWrapped of
  +    true  -> avro_map:new(Type, D);
  +    false -> dict:to_list(D)
  +  end.
  +
  +parse_union(null = Value, Type, ExtractFun, IsWrapped) ->
     %% Union values specified as null
  -  parse_union_ex(?AVRO_NULL, Value, Type, ExtractFun);
  -parse_union({struct, [{ValueTypeNameBin, Value}]}, Type, ExtractFun) ->
  +  parse_union_ex(?AVRO_NULL, Value, Type, ExtractFun, IsWrapped);
  +parse_union({struct, [{ValueTypeNameBin, Value}]}, Type, ExtractFun, IsWrapped) ->
     %% Union value specified as {"type": <value>}
     ValueTypeName = binary_to_list(ValueTypeNameBin),
  -  parse_union_ex(ValueTypeName, Value, Type, ExtractFun);
  -parse_union(_, _, _) ->
  +  parse_union_ex(ValueTypeName, Value, Type, ExtractFun, IsWrapped);
  +parse_union(_, _, _, _) ->
     erlang:error(wrong_union_value).
   
  -parse_union_ex(ValueTypeName, Value, UnionType, ExtractFun) ->
  +parse_union_ex(ValueTypeName, Value, UnionType, ExtractFun, IsWrapped) ->
     case avro_union:lookup_child_type(UnionType, ValueTypeName) of
       {ok, ValueType} ->
  -      %% Here we can create the value directly because we know that
  -      %% the type of value belongs to the union type and we can skip
  -      %% additional looping over union types in avro_union:cast
  -      avro_union:new_direct(UnionType,
  -                            parse_value(Value, ValueType, ExtractFun));
  +      ParsedValue = parse(Value, ValueType, ExtractFun, IsWrapped),
  +      case IsWrapped of
  +        true ->
  +          %% Here we can create the value directly because we know that
  +          %% the type of value belongs to the union type and we can skip
  +          %% additional looping over union types in avro_union:cast
  +          avro_union:new_direct(UnionType, ParsedValue);
  +        false ->
  +          ParsedValue
  +      end;
       false ->
         erlang:error(unknown_type_of_union_value)
     end.
  -
  -parse_fixed(V, Type, _ExtractFun) ->
  -  avro_fixed:new(Type, parse_bytes(V)).
   
   %%%===================================================================
   %%% Tests
  
positive.code: -export([ decode_schema/1
          , decode_schema/2
          , decode_value/3
          , decode_value_jsonx/3
          ]).
  
  -include("erlavro.hrl").
  
  %%%===================================================================
  %%% API
  
negative.code: decode_schema(JsonSchema, ExtractTypeFun) ->
    parse_schema(mochijson3:decode(JsonSchema), "", ExtractTypeFun).
  
  %% jsonx is about 12 times faster than mochijson3 and almost compatible
  %% with it. The one discovered incompatibility is that jsonx performs more
  %% strict checks on incoming json strings and can fail on some cases
  