Skip to content

Commit

Permalink
[feat] add REST-API example, allow indexing without ()
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Sep 27, 2024
1 parent 58a97cd commit 011eae1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions jdict.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
%
% indexing:
% jd.('key1').('subkey1')... can retrieve values that are recursively index keys that are
% jd.key1.subkey1... can also retrieve the same data regardless
% if the underlying data is struct, containers.Map or dictionary
% jd.('key1').('subkey1').v(1) if the subkey key1 is an array, this can retrieve the first element
% jd.('key1').('subkey1').v(1).('subsubkey1') the indexing can be further applied for deeper objects
% jd.('$.key1.subkey1') if the indexing starts with '$' this allows a JSONPath based index
Expand Down Expand Up @@ -42,6 +44,7 @@
%
% % getting values
% jd.('key1').('subkey1') % return jdict(1)
% jd.keys.subkey1 % return jdict(1)
% jd.('key1').('subkey3') % return jdict(obj.key1.subkey3)
% jd.('key1').('subkey3')() % return obj.key1.subkey3
% jd.('key1').('subkey3').v(1) % return jdict({8})
Expand All @@ -58,6 +61,13 @@
% % setting values
% jd.('subkey2') = 'newstr' % setting obj.subkey2 to 'newstr'
%
% % loading complex data from REST-API
% jd = jdict('https://neurojson.io:7777/cotilab/NeuroCaptain_2024');
%
% jd.('Atlas_Age_19_0')
% jd.Atlas_Age_19_0.('Landmark_10_10').('$.._DataLink_')
% jd.Atlas_Age_19_0.Landmark_10_10.('$.._DataLink_')()
%
% license:
% BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details
%
Expand All @@ -77,6 +87,7 @@
catch
obj.data = val;
end
return
end
if (isa(val, 'jdict'))
obj = val;
Expand Down

0 comments on commit 011eae1

Please sign in to comment.