Skip to content

Repository files navigation

The GAP 4 package 'json'
========================

This package defines a mapping between the JSON markup language and GAP.
The built-in datatypes of GAP provide an easy mapping to and from JSON.
This package uses the following mapping between GAP and JSON.

* JSON lists are mapped to GAP lists
* JSON dictionaries are mapped to GAP records
* JSON strings are mapped to GAP strings
* Integers are mapped to GAP integers, non-integer numbers are mapped to Floats
* true, false and null are mapped to true, false and fail respectively
* Non-finite GAP floats use the Python-compatible non-standard spellings NaN, Infinity and -Infinity.
* The historical lowercase spellings nan, inf and -inf are accepted on input.

Note that this library will not map any other GAP types, such as groups,
permutations, to or from JSON. If you wish to map between more complex
types, look at the openmath package, or IO_Pickle in the IO package.

Parsing and string escaping have equivalent C and pure GAP implementations.
The C backend is used when the kernel extension has been compiled; otherwise
the GAP backend takes over automatically. The existing GAP serialisation
methods are shared by both paths, with the kernel accelerating common objects.


Updates
=======

v2.6.0
==========

- Make the kernel extension optional. Without it, the package falls back to a
  JSON parser and string escaper written in GAP.

- Add the JSONTestSuite parsing corpus.

- Add a catch for if nesting is too deep, rather than crash.

- Correctly handle infinity and nan. These are handled in the same way
  Python handles them (technically not valid JSON but a common extension).

v2.5.0
======

- Speed up GapToJsonString by serialising common GAP objects directly in the
  kernel.

- Fix a buffer over-read when escaping a string whose last character is a
  truncated multi-byte UTF-8 sequence, such as [ CHAR_INT(200) ]. Reading past
  the end of the string now yields 0 rather than whatever happened to follow
  it, so the sequence falls back to Latin-1 like any other malformed one
  instead of raising an error or reading out of bounds.

- Avoid format-string vulnerabilities when reporting invalid JSON.

- Remove the unnecessary run-time dependency on GAPDoc.

- Require GAP 4.15 or later.

v2.4.0
======

Allow outputting 'fail', it maps to null (null was already read in as fail)

v2.2.3
======

Internal cleanups for new GAP versions

v2.2.2
======

Use up-to-date methods of loading packages in GAP

v2.2.1
======

Internal cleanups for new GAP versions

v2.2.0
======

Speed up outputting JSON, add new tests

v2.1.1
======

Code cleanups

v2.1.0
======

Change: Keys in dictionaries are now always outputted in lexicographical order


v2.0.1
======

Fix bug in JsonStringToGap, which could lead to entering the break loop.

v2.0.0
======

The Json package now ensures it only outputs valid UTF8. GAP strings which
contain valid UTF8 are outputted unmodified, invalid UTF8 is treated as Latin-1,
and transformed into valid UTF8.


1.2.0 : Fix compiling in recent versions of XCode on Mac OS X
1.1.0 : Fix bug in handling badly formatted integers
1.0.1 : Fix bug in nested structures
1.0.0 : First release

About

A GAP Package for reading and writing JSON

Resources

Stars

4 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages