For performance reasons I want to replace the use of mochijson2 with jiffy. 
My CB webserver returns a large number (like 3000) models which have to be 
encoded into json (the web controller returns {json, proplist})

in boss_json.erl I replaced the calls to mochijson2:encode with jiffy:encode

encode([First|_] = Data, ModelList) ->
    case boss_model_manager:is_model_instance(First, ModelList) of
        true ->
            %mochijson2:encode(lists:map(fun boss_model_manager:to_json/1, 
Data));
    jiffy:encode(lists:map(fun boss_model_manager:to_json/1, Data)Sto_json);
        false ->
            %mochijson2:encode(json_data1(Data, ModelList, []))
    jiffy:encode(json_data1(Data, ModelList, []))
    end;

encode([],_) ->
    "";

encode(Data, ModelList) ->
    case boss_model_manager:is_model_instance (Data, ModelList) of
        true ->
            %mochijson2:encode(boss_model_manager:to_json(Data));
   jiffy:encode(boss_model_manager:to_json(Data));
        false ->
            %mochijson2:encode(json_data1(Data, ModelList, []))
    jiffy:encode(json_data1(Data, ModelList, []))
    end.


When I then exercise CB, I receive the following error


[error] Unhandled Error: throw:{error,
          {invalid_ejson,
              {struct,
                  [{customers,
                       [{struct,
                            [{id,<<"customer-1">>},
                             {cust_id,<<"CUSTOMER1">>},
                             {description,<<"cust1">>},
                             {status,<<"green">>},
                             {status_time,<<"2015-08-05T16:47:33Z">>},
                             {status_time_desc,
                                 <<"2015-08-05 16:47:33.570437">>}]}]},
                   {facilityCount,
                       [{struct,
                            [{count,0},
                             {monitored,0},
                             {green,0},
                             {yellow,0},
                             {red,0},
                             {paused,0}]}]}]}}} Stacktrace: 
[{jiffy,encode,2,[{file,"src/jiffy.erl"},{line,93}]},{boss_web_controller_render,process_action_result,4,[{file,"src/boss/boss_web_controller_render.erl"},{line,178}]},{boss_web_controller,execute_action_inner,9,[{file,"src/boss/boss_web_controller.erl"},{line,290}]},{boss_web_controller_handle_request,process_dynamic_request,5,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,254}]},{boss_web_controller_handle_request,process_request,5,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,240}]},{boss_web_controller_handle_request,set_timer,8,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,160}]},{boss_web_controller_handle_request,build_dynamic_response,5,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,129}]},{boss_web_controller_handle_request,handle_request,4,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,26}]}]


Is anyone fluent enough in the differences between jiffy and mochijson2 to 
help me understand what I need to do?

-- 
You received this message because you are subscribed to the Google Groups 
"ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/chicagoboss/88f3783b-d6c9-449f-91d8-a1aa7af67812%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to