This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Best Way To Parse JSON in C?
I need to parse, validate and query JSON data in a C application, and I am looking for recommendations for the best C JSON library.
The data will be input as strings (char* UTF-8 data), which I first need to validate to ensure the input is valid JSON, and then I will need to perform some simple queries (iterating over the data).
I do not need to produce JSON, I only need to consume it. I also would prefer a parser that will load the whole document into memory rather than a SAX-style parser.
Can anyone recommend a good library, or does anyone have any experience or had problems with libraries?
I have seen the list of libraries in C on JSON.org - are there any good libraries missing from this list?
My requirements are for a small library with as little code / runtime size as possible, and a permissive BSD/MIT style license, since my library will be embedded in other applications.
Thanks,
Marc
I'm recommending Jansson, which I find quite easy to use (and which loads the JSON in memory at once). However, I don't know well all the alternatives, and I don't have a working experience of all of them.
I would choose json-c which is a fast and easy to use JSON parser written in C.
Related
I'm working on a site that is using KaTeX for rendering math. However, the interface for entering the math content is (really) not ideal, so it is actually faster for me to work in an editor, like Sublime Text 3 and import the work; however, an issue I run into is that when I import, I discover various functions / environments aren't supported (i.e. emulated) by KaTeX.
If it were just me working on the material, I would simply learn as I go and consult the KaTeX documentation page; however, I have several contractors working on digitizing content who do not have access to the site (and I don't have the ability to give them access), and so cannot learn by trial-and-error. Instead, I end up with piles of documents that all need to be manually adjusted, to render as desired with KaTeX.
As such, I wanted to assemble a preamble for a LaTeX document that would recreate the abilities (i.e. functions and environments) KaTeX can emulate, and was wondering if such a preamble / package already exists? I have tried a few quick searches, but because I'm looking for something that imitates an emulator, I'm finding it tricky to find the right choice of words to get relevant results.
I wasn't sure if this were best posted here or on the TeX.se - I suspect it falls in-between the two - so I apologize if my guess was wrong and I should've tried there first. Any suggestions would be very much appreciated, as this is creating a substantial bottle-neck in my workflow but is also just outside of my ability to solve on my own.
Supported functions is one thing. To tackle that you might actually stand a fair chance of just tokenizing the input, looking for backslash name sequences and checking them against a list extracted from KaTeX sources to see which are supported.
I guess one could even try to remove all other functions from LaTeX. Or rather hide them, such that the user input can't access them but third party libraries can. Getting rid of language features (as opposed to macros) such as \def would probably be even harder. Better askn on the TeX stack exchange for details of you really want to follow this route.
As an alternative I guess you might be able to perform the check I described above in TeX. Write a macro which reads the current file as plain text instead of TeX source, to perform this analysis. Or some such. But a separate stand-alone tool would be much easier.
If you are going for a separate tool, you might as well write it in JavaScript for Node, and have it run KaTeX on the input. That way you can at least tell whether it will get typeset to something or error out.
Whether the rendering is what you expect from LaTeX may be another question. In general KaTeX aims to reproduce LaTeX behaviour, so any difference might indicate a bug. But bugs exist, so all of this might not avoid the need for checks. How about you just processing the math part of the input with KaTeX to some HTML which authors can check without access to the site?
As for existing tools or macro packages, I know of none, but tool or library questions are off topic on stack exchange anyway.
I've recently started working on a side project whenever I have free time, the side project is a GraphQL Client. I'm making it mostly to learn more about GraphQL. I've got it working and fetching data (Wohoo!). I recently began reading more into Relay and watching talks on it and it seems like it's been maturing so well! What has caught my interest is the babel-relay-plugin and I haven't been able to find many articles or talks on it aside from a talk that briefly did a high-level overview of it. I checked out the relay docs and there wasn't much on it. I tried to follow the source but I don't know where to start or where things actually connect with each other.
From what I've been able to piece together:
You need the graphql schema.json for the plugin to understand how to transform the tagged template strings Relay.QL.
The plugin statically analyzes the Relay.QL tagged template strings and constructs a query representation based on what it knows from the schema.json which I assume is the Immediately-invoked function.
Some of the things I'm trying to understand:
What information does the plugin extract from schema when reading the Relay.QL tagged template string
How to decide what to generate based on Relay.QL.
How is the generated IIFE able to be sent over the network (It probably isn't, I think The plugin creates a query string from this but not sure how this benefits in performance)
My knowledge on this is really minimal and I probably have huge gaps in my understandings of the babel-relay-plugin. But these are some of the things I want to understand further as well as fill in the gaps in my knowledge.
Preface: I have a broad, college knowledge, of a handful of languages (C++, VB,C#,Java, many web languages), so go with which ever you like.
I want to make an android app that compares numbers, but in order to do that I need a database. I'm a one man team, and the numbers get updated biweekly so I want to grab those numbers off of a wiki that gets updated as well.
So my question is: how can I access information from a website using one of the languages above?
What I understand the problem to be: Some entity generates a data set (i.e. numbers) every other week and you have a need to download that data set for treatment (e.g. sorting).
Ideally, the web site maintaining the wiki would provide a Service, like a RESTful interface, to easily gather the data. If that were the case, I'd go with any language that provides easy manipulation of HTTP request & response, and makes your data manipulation easy. As a previous poster said, Java would work well.
If you are stuck with the wiki page, you have a couple of options. You can parse the HTML your browser receives (Perl comes to mind as a decent language for that). Or you can use tools built for that purpose such as the aforementioned Jsoup.
Your question also mentions some implementation details such as needing a database. Evidently, there isn't enough contextual information for me to know whether that's optimal, so I won't address this aspect of the problem.
http://jsoup.org/ is a great Java tool for accessing content on html pages
Consider https://scraperwiki.com/ - it's a site where users can contribute scrapers. It's free as long as you let your scraper be public. The results of your scraper are exposed as csv and JSON.
If you don't know what a "scraper" is, google "screen scraping" - it's a long and frustrating tradition for coders, who have dealt with the same problem you have since the beginning of networked computing.
You could check out :http://web-harvest.sourceforge.net/
For Python, BeautifulSoup is one of the most tolerant HTML parsers out there. The documentation also lists similar libraries in Ruby and Java, so you'll probably find something relevant there.
Some ebooks have copyright-related subscripts on each page. I want to know is there anyway to do this job by programming? Specifically speacking, in C programming language.
It is impossible for them to add this manually, so I think there should be some smart method, but I failed to get any userful information from google.
PDF is a set of structures applied to a subset of the PostScript language. There are a few libraries that should help you manipulate PDF files. You will probably need to know a lot about the formatting of your documents to make this work.
I'm implementing an Apache 2.0.x module in C, to interface with an existing product we have. I need to handle FORM data, most likely using POST but I want to handle the GET case as well.
Nick Kew's Apache Modules book has a section on handling form data. It provides code examples for POST and GET, which return an apr_hash_t of the key+value pairs in the form. parse_form_from_POST marshalls the bucket brigade and flattens it into a buffer, while parse_form_from_GET can simply reference the URL. Both routines rely on a parse_form_from_string routine to walk through each delimited field and extract the information into the hash table.
That would be fine, but it seems like there should be an easier way to do this than adding a couple hundred lines of code to my module. Is there an existing module or routines within apache, apr, or apr-util to extract the field names and associated data from a GET or POST FORM into a structure which C code can more easily access? I cannot find anything relevant, but this seems like a common need for which there should be a solution.
I switched to G-WAN which offers a transparent ANSI C scripts interface for GET and POST forms (and many other goodies like charts, GIF I/O, etc.).
A couple of AJAX examples are available at the GWAN developer page
Hope it helps!
While, on it's surface, this may seem common, cgi-style content handlers in C on apache are pretty rare. Most people just use CGI, FastCGI, or the myriad of frameworks such as mod_perl.
Most of the C apache modules that I've written are targeted at modifying the particular behavior of the web server in specific, targeted ways that are applicable to every request.
If it's at all possible to write your handler outside of an apache module, I would encourage you to pursue that strategy.
I have not yet tried any solution, since I found this SO question as a result of my own frustration with the example in the "Apache Modules" book as well. But here's what I've found, so far. I will update this answer when I have researched more.
Luckily it looks like this is now a solved problem in Apache 2.4 using the ap_parse_form_data funciton.
No idea how well this works compared to your example, but here is a much more concise read_post function.
It is also possible that mod_form could be of value.