[ncl-talk] JSON-NCL

Jonathan Vigh jvigh at ucar.edu
Mon Nov 9 19:35:35 MST 2020


Hi Sui,

I think I've written out JSON format files (very simple ones) in NCL, but I
haven't read them in. I should also mention I'm not an expert in the JSON
format.

I would think you would need to do something like the following:
1. Read in using asciiread as type string (
http://www.ncl.ucar.edu/Applications/read_ascii.shtml).
2. Use the str_index_of_substr function to find all the positions for
opening curly braces '{' and all the closing 'curly braces '}'.
3. Start at the first position in the 'open_curly_brace' index and the last
position in the 'close_curly_brace' index.
4. Check whether any curly braces are found within.
       Check whether any semicolons are found within.
            If so, read in the key:value pair.
       If not, check whether any commas are found within.
             If so, read in the array.
             If not, read in the value.

If you know the structure of what you'll be reading in advance, then it
might not be too hard. If you want NCL to read any possible generalized
JSON, this might be a hard task.

Best,
Jonathan




Jonathan Vigh						
Project Scientist I, Joint Numerical Testbed	
Research Applications Laboratory (RAL)
National Center for Atmospheric Research (NCAR)
P.O. Box 3000                    tel: +1 (303) 497-8205
Boulder, CO 80307-3000   fax: +1 (303) 497-8171Jonathan's Staff Web
Page <http://www.ral.ucar.edu/staff/jvigh/> (CV, publications,
etc.)Tropical Cyclone Guidance Project
<http://hurricanes.ral.ucar.edu/> (real-time hurricane data)

Tropical Cyclone Data Project <https://verif.rap.ucar.edu/tcdata/>
(FLIGHT+, VDM+, TC-OBS datasets)

Hurricane Risk Calculator <https://wxrisk.ucar.edu> (personalizing
hurricane risk assessments for evacuation decision support)

During COVID-19, my working day is definitely not the same as your
working day. Please do not feel obliged to reply to this email outside
of your normal working hours.



On Mon, Nov 9, 2020 at 7:17 PM Rick Brownrigg via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> Hi,
>
> NCL has no built in functionality for reading JSON directly. In principle,
> you could parse the JSON using NCL's various string functions, but in
> practise, I think that would be extremely tedious.
>
> Rick
>
> On Mon, Nov 9, 2020 at 6:23 PM 时光足迹 via ncl-talk <
> ncl-talk at mailman.ucar.edu> wrote:
>
>> Hi there, I wonder how to deal with JSON files with NCL(NCAR COMMAND
>> LANGUAGE), thank you a lot!
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at mailman.ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at mailman.ucar.edu
> List instructions, subscriber options, unsubscribe:
> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20201109/3d0ec82a/attachment.html>


More information about the ncl-talk mailing list