public class JSONOne extends Object
Single class containing classes for representing JSON objects programmatically. Includes pretty print and parser. NOT like the world needs another JSON package. But... 1) it was an interesting exercise 2) perhaps someone needs something to adapt from, etc.
Very vanilla. Null, Boolean, String, Number, Array and Map objects.
Parser (well, the scanner actually) is inefficient for large objects; it expects a single String object for input. So there is that. Would be not too tough to remedy, but you'd need pushback/lookahead etc.
Should handle backslash escaping properly, ꯍ unicode, etc.
Also, in this day and age of awesome parser frameworks, it was really fun to write a parser by hand. I used: http://www.craftinginterpreters.com/ as a refresher for how to do old school scanning/parsing. I swear I have an actual book around somewhere, but I could not find it, and I did not feel like digging through Knuth this time.
| Modifier and Type | Class and Description |
|---|---|
static class |
JSONOne.JArray
JSON Array class.
|
static class |
JSONOne.JBoolean
Boolean value
|
static class |
JSONOne.JMap
JSON Map value.
|
static class |
JSONOne.JNull
Null value.
|
static class |
JSONOne.JNumber
Number object.
|
static interface |
JSONOne.JObject
A JSON object.
|
static class |
JSONOne.JString
Holds a string value.
|
static class |
JSONOne.Parser
Parser, parses reasonably standard JSON.
|
static class |
JSONOne.Type
JSON value types
|
| Constructor and Description |
|---|
JSONOne() |
| Modifier and Type | Method and Description |
|---|---|
static CharSequence |
escapeString(CharSequence seq) |
static CharSequence |
unescapeString(CharSequence seq) |
public static CharSequence unescapeString(CharSequence seq)
public static CharSequence escapeString(CharSequence seq)
Copyright © 2020. All rights reserved.