You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: export.m
    path of file: ./repos/spinw/swfiles/@swpref
    
    the code of the file until where you have to start completion: function success = export(obj,location)
% saves swpref object into a file
%
% ### Syntax
%
% `success = export(obj,location)`
%
% `success = export(obj)`
%
% ### Description
%
% `success = export(obj,location)` writes the preferences given in `obj` to
% a file location given by `location`. The file is in a basic `.json`
% format.

    
function success = export(obj,location)
% saves swpref object into a file
%
% ### Syntax
%
% `success = export(obj,location)`
%
% `success = export(obj)`
%
% ### Description
%
% `success = export(obj,location)` writes the preferences given in `obj` to
% a file location given by `location`. The file is in a basic `.json`
% format.
%
% `success = export(obj)` writes the preferences given in `obj` to
% the users home folder as `swprefs.json`. The file is in a basic `.json`
% format.
%
% ### See Also
%
% [swpref.import]
%

props = obj.props;

if nargin == 1
    location = [userpath filesep 'swprefs.json'];
end