Giter Site home page Giter Site logo

yajl-fort's People

Contributors

nncarlson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

ugiwgh

yajl-fort's Issues

An experimental JSON data container

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.