nncarlson / yajl-fort Goto Github PK
View Code? Open in Web Editor NEWYAJL-Fort: A modern Fortran interface to the YAJL library
License: MIT License
YAJL-Fort: A modern Fortran interface to the YAJL library
License: MIT License
Builds 6212 and 6216 of the NAG 6.2 compiler are giving segfaults on the json-ex1 and json-ex8 unit tests. These last worked with build 6210, and earlier versions. A reproducer was reported to NAG; see https://github.com/nncarlson/fortran-compiler-tests/blob/master/nag-bugs/nag-20180819.f90
With regularity I am approached by someone looking for a Fortran solution for reading JSON data from a file, presumably into some container where the data can be randomly accessed, and who are baffled with how to use YAJL-Fort for that purpose. The confusion is understandable because YAJL-Fort isn't that solution; it is only intended to be a piece of that solution. As described in the README, it is an event-driven (SAX style) parser that invokes client-provided callback procedures when specific tokens, like '{', ']', or a , are parsed. It is up to the client to do something useful with those bits of data. (Of course it is really the YAJL C library that does all the heavy lifting; YAJL-Fort is merely an interface to the library.) What is needed are example use-cases of YAJL-Fort. The included example that simply echoes the JSON input is really too simple to provide much guidance. The Petaca library provides a serious example in the code that populates a "parameter list" container from JSON data, but it is perhaps too complex because the container is only compatible with a subset of the JSON format, and a significant part of the callbacks are concerned with ensuring that the JSON data belongs to that subset.
With this in mind, I have written an experimental module, json.F90
, that defines a container for arbitrary JSON data and provides procedures for populating the container with JSON data read from a file or a string. The procedures provide a good example of how to use YAJL-Fort. But beyond that, this module is the beginnings of a full solution for reading, writing, and working with arbitrary JSON data1. In this regard it is very similar to JSON-Fortran, though with much more limited functionality at this point.
By default the json.F90
module and its associated tests are not compiled. Use the cmake option -DENABLE_JSON=ON
to build them. The tests/examples are located in test/json
.
Your comments/suggestions are solicited.
1 General JSON values do not actually mesh all that well with natural Fortran data structures like arrays (rectangular and of homogeneous type) and this makes working with general JSON data rather awkward. If the real need is for a JSON-like hierarchical data container with values that match Fortran data structures, then Petaca's "parameter list" is what you want; it is expressible as JSON, but it is much easier to work with.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.