In Laravel 5.5
Route::get('/test2', function (){
    $data = (object) [];
    return response()->json($data);
});
it always returns [] rather than {}. 
another code:
Route::get('/test2', function (){
    $data = (object) [];
    return json_encode($data);
});
it correctly returns {}
I want to use response()->json() helper to return empty object instead of empty array, is it possible?
json_encode. Unless yourResponseFactorydoes not return the defaultJsonResponse. Could you try this:return response()->json($data, 200, [], JSON_FORCE_OBJECT);