ajson
A JSON parser and serialiser for ABAP that parses into a flexible, unstructured node tree rather than a fixed target structure, converting to one only when asked through to_abap.
Deserialising JSON into ABAP normally means fixing a target structure up front; ajson parses into a form that is 'not fixed to any predefined data structure, allowing to modify the parsed data, selectively access its parts and slice subsections of it', and converts to a fixed structure only when asked, through to_abap. That flexibility is useful for slicing off a shared envelope, such as separating a response's top-level fields from its payload for different layers of an application to handle. It also filters a JSON tree to drop empty values or chosen paths, maps node names between casing conventions such as snake_case and camelCase, iterates array items or object members, and diffs two JSON documents. It works from ABAP release 7.02 and installs through abapGitabapGitA Git client written in ABAP that runs inside the system, so objects are cloned, pulled and pushed without leaving it; with no package manager in ABAP, a cloned repository is how code is distributed.community org, abap.
Facts
Where it sits
Who is behind it
In the atlas: maintains 5, contributes to 11@sbcguamaintainerAlbert MinkContributes to this
In the atlas: maintains 1, contributes to 8@albertminkChristian GünterContributes to this
In the atlas: maintains 1, contributes to 12@christianguenter2Christian WildtContributes to this
In the atlas: contributes to 8@cwildtJaime Rodriguez CapoteContributes to this
In the atlas: maintains 1, contributes to 9@jrodriguez-rcJXYSGX7CContributes to this
In the atlas: contributes to 2@JXYSGX7CLars HvamContributes to this
In the atlas: maintains 13, contributes to 92, wrote 1@larshpMathieu LawnikContributes to this
In the atlas: contributes to 1@mathieulawnikMarc BernardContributes to this
In the atlas: contributes to 26@mbtoolsoblomov-devContributes to this
In the atlas: maintains 4, contributes to 44@oblomov-devPostavkaContributes to this
In the atlas: contributes to 1@Postavka12 contributors
What it declares
Every artifact
- Type
- Package
- Origin
- Independently maintained
As a package
- Where it runs
- does not say
- Distributed through
- abapGit
Connections
Turning typed data into JSON, CSV or protobuf and back
Class-based wrapper around STRUST certificate management
Git client written in ABAP that runs inside the system
Download
README
quoted from sbcgua/ajson under MIT, read
abap json (ajson)
Yet another JSON parser/serializer for ABAP. It works with release 7.02 or higher.
Recent breaking changes
Since v1.2.0:
- there are changes in mapper interface, see "Mapping (field renaming)" section in the docs. In essence, implement
rename_nodemethod if needed,to_jsonandto_abapwill be deprecated. As well ascreate_field_mappingandcreate_camel_casemappers - potentially
create_emptystatic method may be deprecated. It is considered to usenewinstead (and/or direct creationcreate object). Under consideration, post an issue if you have an opinion on this subject. - also
create_fromis potentially suboptimal, so preferclone,filterandmapinstead.
Features
- parse into a flexible form, not fixed to any predefined data structure, allowing to modify the parsed data, selectively access its parts and slice subsections of it
- slicing can be particularly useful for REST header separation e.g.
{ "success": 1, "error": "", "payload": {...} }where 1st level attrs are processed in one layer of your application and payload in another (and can differ from request to request)
- slicing can be particularly useful for REST header separation e.g.
- allows conversion to fixed abap structures/tables (
to_abap) - convenient interface to manipulate the data -
set( value ),set( structure ),set( table ),set( another_instance_of_ajson ), also typed e.g.set_date- also
setxfor text-based value setting likesetx( '/a/b:123' )(useful e.g. for constants in APIs or in unit-tests)
- also
- seralization to string
- freezing (read only) instance content
- filtering. Create a JSON skipping empty values, predefined paths, or your custom filter.
- mapping - rule-based changing node names (e.g. snake case to camel case, upper/lower case)
- iterating through the array items or object members
- utility to calculate difference between 2 JSONs
Installed using abapGit, see also Installation section of the documentation.
Example of usage
data r type ref to zif_ajson.
data fragment type ref to zif_ajson.
r = zcl_ajson=>parse( '{"success": 1, "error": "", "payload": {"text": "hello"}}' ).
r->get( '/success' ). " returns "1"
r->get_integer( '/success' ). " returns 1 (number)
r->get_boolean( '/success' ). " returns "X" (abap_true - because not empty)
r->get( '/payload/text' ). " returns "hello"
r->members( '/' ). " returns table of "success", "error", "payload"
fragment = r->slice( '/payload' ).
fragment->get( '/text' ). " returns "hello" (the root has changed)
fragment->set(
iv_path = '/text'
iv_val = 'new text' ).
fragment->stringify( ). " {"text":"new text"}
See a lot more examples and usages in the Documentation.
References
- Forked from abaplint-abap-backend originally, at early stages
- The package is unit tested dynamically in Github actions thanks to the abap transpiler by @larshp
- Publication at SCN:
- Bicycles. #2 – AJSON – yet another abap json parser and serializer
- JSON alternative to maintenance views in ABAP
- Both above and future articles are in the Blog articles
History
Others providing
Compare all 12 on the Serialisation page →- ABAP JSON APIABAP JSON APIA JSON renderer and parser for ABAP built on the standard identity transformation, adding automatic camelCase conversion and support for polymorphic arrays.independent, abapJSON renderer and parser for ABAP with camelCase conversion
- zcl_mdp_jsonzcl_mdp_jsonAn ABAP library that generates and parses JSON strings, documented in the repository's wiki rather than its README, which names no ABAP release or installation method.independent, abapABAP library generating and parsing JSON strings
- JSON2ABAPTypeJSON2ABAPTypeA generator that produces an ABAP type definition from a JSON structure, with the repository holding the code and pointing to a blog article and an SAP blog post for the rest.independent, abapGenerator of ABAP type definitions from JSON structures
- abap-protobufabap-protobufAn implementation of Protocol Buffers in ABAP, stating support for proto2 syntax only; its repository description names gRPC, which the README says nothing further about.independent, abapProtocol Buffers (proto2) implementation in ABAP
- ZASISZASISThe ABAP String Interpreter: an ABAP component that reads named field values out of an unstructured string, such as a barcode or scanner payload, through regex RuleSets configured in a Fiori app and called from ABAP or over HTTP.independent, abapRegex RuleSets that read barcode strings into named fields
- ABAP ArchitectABAP ArchitectAn Eclipse plug-in that generates ABAP type definitions and parsing code from a pasted JSON or XML sample and creates the matching DDIC objects in a connected system over ADT.independent, abapEclipse plug-in turning JSON or XML into ABAP types and DDIC objects
- ABAP to JSON serializer and deserializerABAP to JSON serializer and deserializerAn open-source Z* version of SAP's standard /UI2/CL_JSON class, which serialises ABAP data to JSON and reads it back, installed with abapGit and needing SAP_BASIS 7.31 or later.sap official, abapOpen-source Z* version of /UI2/CL_JSON for ABAP to JSON
- sbcgua/text2tabsbcgua/text2tabA library that parses TAB-delimited text into an internal table of any flat ABAP structure, with non-strict, header and type-less modes, and serialises tables back to text in configurable formats.independent, abapParser of TAB-delimited text into ABAP internal tables and back
- ABAP JSON Encoder/DecoderABAP JSON Encoder/DecoderA JSON encoder and decoder for ABAP, modelled on Go's encoding/json package, installed through abapGit with no other required package and documentation still marked under construction.independent, abapJSON encoder and decoder for ABAP, modelled on Go's encoding/json
- ZwdCSVZwdCSVA CSV parser and generator for ABAP that follows RFC 4180, including line breaks embedded inside quoted fields, for strings and for files on the application server and the frontend.independent, abapRFC 4180 CSV parser and generator for ABAP
- ABAP CSV ManagerABAP CSV ManagerA configurable CSV reader and writer for ABAP, with per-field format, validation and column-mapping options, reading into a flat or a dynamically typed internal table.independent, abapConfigurable CSV reader and writer for ABAP
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
abaplint
Contributors
History in the atlas
- First seen.
For your agent
- Ref
artifact:sbcgua-ajson- JSON
- /artifacts/sbcgua-ajson.json
- MCP
- Connecting an agent