anchor.diff:      list_to_binary(integer_to_list(X));
   to_json_type(_, void) -> <<"ok">>;
   to_json_type(X, {type,_,<<"uint", _/binary>>,_}) when is_integer(X), X >= 0 ->
  -    list_to_binary(integer_to_list(X));
  -to_json_type(false, {type,_,<<"boolean">>,_}) -> <<"0">>;
  -to_json_type(true, {type,_,<<"boolean">>,_}) -> <<"1">>;
  -to_json_type(X, {type,_,<<"enumeration">>, En} = T) ->
  -    case [lists:keyfind(value,1,I1) || {enum,_,E1,I1} <- En,
  -				       E1 == X] of
  -	[{value,_,V,_}] ->
  -	    V;
  -	[] ->
  -	    error({type_error, [X, T]})
  +    X;
  +to_json_type(false, {type,_,<<"boolean">>,_}) -> false;
  +to_json_type(true, {type,_,<<"boolean">>,_}) -> true;
  +to_json_type(X0, {type,_,<<"enumeration">>, En} = T) ->
  +    %% We always return the key (binary) - not the value (integer).
  +    %% This seems to be in keeping with how NETCONF does it.
  +    X = if is_integer(X0) -> list_to_binary(integer_to_list(X0));
  +           is_binary(X0)  -> X0;
  +           is_list(X0) -> list_to_binary(X0)
  +        end,
  +    case find_enum(En, X) of
  +        [] -> error({type_error, [X0, T]});
  +        [{Key, _}] ->
  +            Key;
  +        [{K1, V1}, {K2, V2}] ->
  +            %% Either V1 or V2 must be equal to X, or it's an error
  +            if V1 == X -> K1;
  +               V2 == X -> K2;
  +               true -> error({type_error, [X0, T]})
  +            end
       end;
   to_json_type(X, {type, _, <<"union">>, Ts} = Type) ->
       to_json_type_union(Ts, X, Type);
  +to_json_type(_, {type, _, <<"empty">>, _}) -> <<>>;
   to_json_type(X, _) ->
       X.
   
  
positive.code: 
  i(I) ->
      lists:duplicate(I*4+4,$\s) .
  
negative.code: %%%---- END COPYRIGHT ---------------------------------------------------------
  -module(yang_json).
  -compile(export_all).
  
  -ifdef(TEST).
  -include_lib("eunit/include/eunit.hrl").
  -endif.
  
  -define(fd(Fl, A, B), Fl when A =< X, X =< B).
  
  