Be the first to rate this file! 57 downloads (last 30 days) File Size: 3.21 KB File ID: #25713

Highly portable JSON-input parser

by Nedialko

 

02 Nov 2009 (Updated 03 Nov 2009)

Code covered by BSD License  

For any version of Matlab that may still be in use by the fileexchange community.

Download Now | Watch this File

File Information
Description

The JSON quickly gains popularity for a good reason. To paraphrase Christophe Delord (http://christophe.delord.free.fr/tpg/)
JSON is born from a simple statement:
A simple human-like meta-language will quickly
justify its use in such cases as data exchange over the web (e.g. Google translate), configuration files, etc.

See

http://sites.google.com/site/sim4stim/2clicks/a2t.html

 for an example of AUTOMATIC, PORTABLE & REUSABLE creation of GUI sets for Matlab.
(Note: p_json.m is at the core of this example too)

Hence it is worth the while to provide this novel facility to the widest possible audience of Matlab users.

Based on work from:

http://json-schema.org/
      &
http://www.mathworks.com/matlabcentral/fileexchange/ ::

 F.Glineur 23393-another-json-parser: Faster, Clearer & More robust than #20565
 J.Feenstra 20565-json-parser

This submission also provides a very simple (yet meaningful) use example (see also the screenshot).

Your test script (called a0t on the screenshot) may look like:

% ---------------------------------------------------------

fName = 'test02.jon';

fid = fopen(fName,'rt'); inString = fscanf(fid,'%c'); fclose(fid);

data = p_json(inString)

% ---------------------------------------------------------

and hence
 
inString == verbatim the 'test02.jon' TEXT input file,

provided in the .zip (see links below for more detail and more definitions):

% =========================================================
inString =

{
  "$schema":
  {"properties":{
    "name": {"type":"string"},
    "age" : {"type":"integer",
      "maximum":125,
      "optional":true}
   },
   "type" : "object"
  },
  "name" : "John Doe",
  "age" : 30
}

% =========================================================

*** See also:

Given the topical nature of the JSO notation we invite the user to take a look at places like:

http://en.wikipedia.org/wiki/JSON

http://json-schema.org/

http://json.org/

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
JSON Parser, (another) JSON Parser

MATLAB release MATLAB 5.2 (R10)
Zip File Content  
Other Files license.txt,
p_json.m,
test02.jon
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
03 Nov 2009

Corrected typos & added the auto-GUI example & its link

Tag Activity for this File
Tag Applied By Date/Time
communications Nedialko 03 Nov 2009 12:12:03
data export Nedialko 03 Nov 2009 12:12:03
data import Nedialko 03 Nov 2009 12:12:03
demo Nedialko 03 Nov 2009 12:12:03
gui Nedialko 03 Nov 2009 12:12:03
mathematics Nedialko 03 Nov 2009 12:12:03
signal processing Nedialko 03 Nov 2009 12:12:03
simulation Nedialko 03 Nov 2009 12:12:03
embedded code Nedialko 03 Nov 2009 12:12:03
modeling Nedialko 03 Nov 2009 12:12:03
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com