jsonx icon indicating copy to clipboard operation
jsonx copied to clipboard

Error in output.

Open egorovd opened this issue 10 years ago • 0 comments

-module(json_t).

-record(json_t, {
    name :: binary(),
    age = 0 :: pos_integer(),
    spouse :: #json_t{}
}).

-record(json_t2, {
  name :: binary(),
  age = 0 :: pos_integer(),
  spouse :: #json_t{}
}).

encoder1() ->
    jsonx:encoder([{json_t, record_info(fields, json_t)},
                             {json_t2, record_info(fields, json_t2)} ], 
                             [{ignore, [undefined]}]).

a() ->
  R = #json_t2{ name = <<"John">>, age = 32, spouse = [#json_t{}] },
  Encoder = encoder1(),
  Res = Encoder(R),
  io:format("~p ~n",[Res]).

RESULT:

<<"{"name": "John","age": 32,"spouse": [{,"age": 0}]}">>

If first field in record == undefined.

egorovd avatar Mar 16 '14 11:03 egorovd