A major goal of the Stringtree software project has always been to be as compatible as possible with all the software people are using for their Java development. Naturally that also includes whatever Java version is being used.
For a long time I interpreted this goal as implying that all Stringtree code should run on all Java versions from Java 1.2 onwards. Java 1.4, however, introduced some compelling new features including built-in regular-expression handling. For a few years I still tried to ensure that most code was still 1.2-compatible (for example by using Ant to swap in a third-party regular-expression library while building a jar file), while also providing a Java 1.4 version. Eventually, use of Java versions prior to 1.4 declined enough that I felt comfortable removing the complicated pre-1.4 version.
For the last few years I have been very careful to keep all my Stringtree code compatible with all versions of Java from 1.4 upwards. Now, however, the pressure is building again to move over to Java 5. In my day-to-day coding I develop with Java 5 and make increasing use of Java 5 features such as the enhanced for loop, the Iterable interface, enums, generics, autoboxing, varargs and so on. It would be very nice to be able to update the Stringtree codebase to use these features too.
Occasionally a Java 5-specific detail has crept in to a Stringtree library, and I have soon received comments or emails pointing this out. I haven’t noticed this for a while, which might indicate either that I have been especially careful, or that I there are no longer any/many people developing with Stringtree code who are still limited to Java 1.4.
If you are reading this and you still require Java 1.4 support, please let me know. Likewise, if you have thrown off the shackles of 1.4 within the last year or so or are desperately hoping for a Java 5 Stringtree that would be good to know too.
Is it time for Java 5 yet?
Posted by Stringtree as Friki, General, HTTPClient, Inkling, JSON, Mojasef, Projects, Templater at 7:59 PM PDT
No Comments »
Along with the latest release of Stringtree I have released a new Stringtree JSON.
The major change is the provision of an extra version of JSONReader.read which takes a CharacterIterator to allow reading of JSON from within a larger body of text.
I’ve also had another try at ensuring that it is Java 1.4 compatible. Please let me know of any problems you encounter, particularly Java1.4 incompatibility issues.
Download from Sourceforge as usual, and the source is in with Stringtree 2.0.9.
Have fun.
Posted by Stringtree as JSON, Projects at 11:42 AM PDT
6 Comments »
I just had a pleasant email exchange with someone who is interested in embedding Stringtree JSON in another project. In this particular case, the basic functionality of the JSONReader is fine, but the calling API was not quite aligned with what they need.
So now, as well as reading JSON from a String, you now have the ability to read JSON from a CharacterIterator. This was a neat changes, as Stringtree JSONReader uses a CharacterIterator internally anyway, so the extra method actually does a bit less than the original one.
For “power users”, there is actually an extra method. When JSONReader starts reading from a CharacterIterator it’s not entirely clear whether it should get its first character by calling current() to get a character already read once, or by calling next() to get the next unread character, or by calling first() to get the first character of the sequence. With this in mind I have provided a read(CharacterIterator ci, int start), where start can be JSONReader.START, JSONReader.NEXT, or JSONReader.CURRENT.
This update is available in sourceforge subversion, and will be included in the next release of Stringtree and Stringtree JSON.
Posted by Stringtree as General, JSON, Projects at 10:52 PM PDT
2 Comments »
Hot on the heels of the long-awaited and bountiful Stringtree 2.0.5 release comes a somewhat less momentous 2.0.6. I had tentatively planned to make the next release at the end of April 2007, but, as Jörn Zaefferer pointed out, I had forgotten something I had promised to do.
As an overall policy, all code in the Stringtree project and its subprojects should not depend on anything later than Java 1.4. Inadvertently, however, a dependency on a new interface (Iterable) introduced in Java 5 had crept into org.stringtree.json.JSONWriter.
It’s only a one-line change if you are using the source code, but this problem is is most significant for people who just wish to use Stringtree JSON “out of the box” with Java 1.4. So I have brought forward the 2.0.6 release to include it.
Also in this release is Jim Yingst’s improvement to the “bean” processing in JSONWriter which makes the code more usable with “partially public” objects (such as public inner classes).
Feel free to download the full Stringtree jar, the Stringtree source code, or the lean and mean Stringtree JSON jar.
Posted by Stringtree as JSON, Projects at 3:43 PM PDT
3 Comments »
It’s been a while since I put out an updated version of Stringtree. There have been a steady stream of changes and additions, so I reckon it’s time for a new one. Say hello to Stringtree 2.0.5.
Changes in this version:
- added templater test for calling a pipe on an object before multiplying
- added initial mock implementation of JDBC classes
- reintroduced some Tract Fetcher tests. Not all working yet, though.
- added quot and apos to XMLEscaper
- migrate juicer & tests
- migrate workflow and tests
- reformat Juicer code to new standard
- add juicer tests into main test sequence
- add workflow tests into main test sequence
- go through all code and check formatting
- write JSON validator
- add MapResultRowListener to collect name/value pairs from database results
- (spec) support use of @ and ! with no names as resource and filesystem includes
- (JSON) write documentation and examples
- (JSON) notify JSON.org
- modify build script to generate separate stringtree-json jar
One of the most significant changes is that JSON now gets its own sourceforge binary release and even its own web page. Stringtree JSON has been a surprising success, so I thought I’d make it easier for people to understand and use it without the rest of the Stringtree library.
Posted by Stringtree as JSON, Projects at 11:11 AM PDT
7 Comments »
As promised, I have eventually got around to writing the final part of the JSON trilogy, although maybe I should have waited until Friday the 13th
Along with the new JSONValidator class, I have also added validating versions of the existing JSONReader and JSONWriter classes so that those who wish to always validate can do so in a simple manner. By default the validator generates a simple error summary to standard output, although this behaviour is easily overridden by supplying a custom implementation of JSONErrorListener. As usual there are plenty of test cases to take a look at to see examples of how to use the various classes, and there are no external dependencies to you can plug these classes into your apps or frameworks without disturbing or requiring anything else.
All the files in the Stringtree JSON suite are currently available from subversion at
the tests are available from subversion at
or if you just want the meat, you can download the files individually:
Please check these out if you are interested in a fast, lean Java JSON implementation. I’d love to hear any comments and suggestions, ideally before I include these files in the next release of Stringtree.
Posted by Stringtree as JSON, Projects at 4:41 PM PST
15 Comments »
It seems that my lean Java JSON implementation has caught some people’s attention. Not only have helpful folks submitted patches on this blog, but it’s actually getting use in real applications. With any luck I’ll get a bit of slack to work on the missing validator compopnent soon.
In the meanwhile, I have fixed the problem in JSONReader reported by “Sonny Gill” and “jlist”, and added a test case for that behaviour. I’d really appreciate it if a few folks could check out the latest version from https://svn.sourceforge.net/svnroot/stringtree/trunk (or direct from JSONReader.java) and try it out.
There will probably be a new release of the full Stringtree package sometime in the next week or two.
Posted by Stringtree as JSON, Projects at 2:27 PM PST
No Comments »
A few days ago I was reading Slava Pestov’s blog about his continuing development of his language “factor”. It’s always interesting, but the post that got me coding was his mention of JSON, the “java script object notation”. In particular, the pointer to a large and rambling Java implementation.
I reckoned I could do a smaller/simpler one, so I had a go. I used a strict test-first methodology and came up with a JSON reader in about 190 lines of Java and a JSON writer in about 150 lines of Java. Both assume correct syntax, so the third part is a validator, which I haven’t done yet.
My examples are not as concise as the Factor implementations, but they are a whole lot smaller than the jroller one, and they have absolutely no external dependecies.
Unfortunately I’m having trouble with access to sourceforge at the moment, but when I get it sorted out this code (and all the tests which drove it) will be added to the Stringtree project.
[Update] The validator is now written. See this more recent post for details
Posted by Stringtree as JSON, Projects at 11:36 AM PDT
17 Comments »