Categorygithub.com/johnsiilver/jsonfs
modulepackage
0.0.0-20221206105953-e9a6ec692acd
Repository: https://github.com/johnsiilver/jsonfs.git
Documentation: pkg.go.dev

# README

jsonfs - absolutely NOT production ready.

This was a thought experiment on a tool for doing JSON discovery where you don't have a schema.

It treats the JSON as a filesystem. Directories represents JSON dictionaries and arrays. Files represents JSON basic values.

These tie in with an in memory fs.FS filesystem that will allow you to use filesystem tools to work with the data. This seems nicer to use than a map[string]any or []any that you might otherwise deal with from the stdlib.

There is a diskfs that also implements fs.FS . I have not put it through its paces. The idea was to allow you to copy whatever you want from the memfs to the diskfs and then you could use all the filesystem tools that Linux gives you.

At this point, what I guarantee is that the Marshal() and Unmarshal() do work. The Unmarshal() is slower because we provide more structures, which means it takes longer.

Marshal() on the other hand is faster and much less memory intensive.

The statemachines for marshal and unmarshal are pretty good. At some point I may decouple those into their own library to allow building anyone to build JSON tooling.

Here are the benchmarks I referred to:

BenchmarkMarshalJSONSmall-10          	  256087	      4573 ns/op	       0 B/op	       0 allocs/op
BenchmarkMarshalJSONStdlibSmall-10    	  241816	      4981 ns/op	    2304 B/op	      51 allocs/op
BenchmarkMarshalJSONLarge-10          	       7	 143744732 ns/op	 9633560 B/op	   11255 allocs/op
BenchmarkMarshalJSONStdlibLarge-10    	       7	 143856131 ns/op	101807982 B/op	 1571144 allocs/op
BenchmarkUnmarshalSmall-10            	  134758	      8933 ns/op	    7281 B/op	     173 allocs/op
BenchmarkStdlibUnmarshalSmall-10    	  209151	      5903 ns/op	    2672 B/op	      66 allocs/op
BenchmarkUnmarshalLarge-10            	       4	 250373635 ns/op	240508578 B/op	 5336230 allocs/op
BenchmarkStdlibUnmarshalLarge-10    	       6	 187222674 ns/op	99413457 B/op	 1750078 allocs/op
BenchmarkObjectWalk-10                	       4	 284417094 ns/op	145693142 B/op	 3442589 allocs/op
BenchmarkStdlibObjectWalk-10          	      10	 104694233 ns/op	58166933 B/op	 1551677 allocs/op

# Packages

No description provided by the author

# Functions

Append appends to the Directory array all filesOrDirs passed.
No description provided by the author
ArraySet sets the value at index to fd.
No description provided by the author
CP will make a copy of the File or Directory and return it.
DataType is a more expensive version of ValueCheck for just file data.
No description provided by the author
IsArray reads a directory in fsys at path to determine if it is an array.
MarshalJSON takes a Directory and outputs it as JSON to a file writer.
MustNewArray is like NewArray, but errors cause a panic.
MustNewDir is like NewDirectory, but errors cause a panic.
MustNewFile is like NewFile except any error panics.
NewArray creates a new Directory that represents a JSON array.
NewDir creates a new Directory with name and includes the files and directories passed.
NewDiskFS creates a new DiskFS rooted at path string.
NewFile creates a new file named "name" with value []byte.
NewMemFS creates a new MemFS from a Directory that will act as the root.
OpenDiskFS opens a DiskFS that exists on the filesystem at path.
SskipSpace skips all spaces in the reader.
UnmarshalJSON unmarshals a single JSON object from an io.Reader.
UnmarshalStream unmarshals a stream of JSON objects from a reader.
UnsafeGetBytes extracts the []byte from a string.
ValueCheck tells what the next JSON value in a *bufio.Reader is.
WriteOut writes to "w" all "values".

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Directory represents an object or array in JSON nomenclature.
DiskFS provides an FS for OS access.
File represents a value in JSON.
FileInfo implements fs.FileInfo.
MemFS represents an inmemory filesystem for storing JSON data.
No description provided by the author
Stream is a stream object from UnmarshalStream().

# Interfaces

DirectoryFS provides methods for reading and writing a Directory to a Filesystem.
FileOrDir stands can hold a File or Directory.
FS details the interfaces that a filesytem must have in order to be used by jsonfs purposes.
No description provided by the author

# Type aliases

FileType represents the data stored in a File.
No description provided by the author