Skip to content
Snippets Groups Projects
Commit 852f9b67 authored by fangq's avatar fangq
Browse files

support JSONP in savejson

git-svn-id: http://svn.code.sf.net/p/iso2mesh/code/trunk/jsonlab@370 786e58fb-9377-0410-9ff7-e4ac0ac0635c
parent 5e88bfe1
No related branches found
No related tags found
No related merge requests found
......@@ -54,6 +54,9 @@ function json=savejson(rootname,obj,varargin)
% 1e999 to represent Inf, they can set opt.Inf to '$11e999'
% opt.NaN ['"_NaN_"'|string]: a customized regular expression pattern
% to represent NaN
% opt.JSONP [''|string]: to generate a JSONP output (JSON with padding),
% for example, if opt.JSON='foo', the JSON data is
% wrapped inside a function call as 'foo(...);'
% opt can be replaced by a list of ('param',value) pairs. The param
% string is equivallent to a field in opt.
% output:
......@@ -98,6 +101,11 @@ else
json=sprintf('{\n%s\n}\n',json);
end
jsonp=jsonopt('JSONP','',opt);
if(~isempty(jsonp))
json=sprintf('%s(%s);\n',jsonp,json);
end
% save to a file if FileName is set, suggested by Patrick Rapin
if(~isempty(jsonopt('FileName','',opt)))
fid = fopen(opt.FileName, 'wt');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment