Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@abapify/asjson-parser

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@abapify/asjson-parser

[asJSON](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap_asjson.htm) - Canonical JSON Representation

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
59
increased by5800%
Maintainers
1
Weekly downloads
 
Created
Source

ABAP asJSON Parser

asJSON - Canonical JSON Representation

General asJSON format is based on %heap object delivering values and type metadata

So when we have a code like this:

REPORT ZTEST_HEAP.

start-of-selection.

types:
  begin of payload_ts,
    i type i,
    i_ref type ref to i,
  end of payload_ts.


  data(payload) = value payload_ts(
    i = 123
    i_ref = new #( 123 )
  ).

  data(json) = cl_sxml_string_writer=>create( if_sxml=>co_xt_json ).

  call transformation id
  source data = payload
        result xml json.

  cl_demo_output=>display_json( json = json->get_output( ) ).

the output it generates will be:

{
 "DATA":
 {
  "I":123,
  "I_REF":
  {
   "%ref":"#d1"
  }
 },
 "%heap":
 {
  "d1":
  {
   "%type":"xsd:int",
   "%val":123
  }
 }

The following library allows us to parse this payload as if we would deal with a regular ABAP object without data references

The code below

import { parse } from '@abapify/asjson-parser';
const parser;
console.log(parse(json));

would print the object like this:

{
 "DATA":
 {
  "I":123,
  "I_REF": 123
 }

Usage

  • as a parser
import { parse } from '@abapify/asjson-parser';
console.log(parse(json));
  • as a transformer
import { transform } from '@abapify/asjson-parser';
const object = JSON.parse(json);
console.log(transform(object));
  • as a proxy (returns a proxied object)
import { proxy } from '@abapify/asjson-parser';
const object = JSON.parse(json);
console.log(proxy(object));

FAQs

Package last updated on 20 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc