@abapify/asjson-parser 0.4.34 → 0.4.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -87
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,105 +1,33 @@
|
|
|
1
1
|
# @abapify/asjson-parser
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@abapify/asjson-parser)
|
|
4
|
+
[](https://github.com/abapify/adt-cli/blob/main/LICENSE)
|
|
4
5
|
|
|
5
|
-
ABAP asJSON
|
|
6
|
+
Parser for SAP ABAP asJSON canonical format — maps ABAP asJSON payloads to/from plain JavaScript objects.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
## Install
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
So when we have a code like this:
|
|
12
|
-
|
|
13
|
-
```abap
|
|
14
|
-
REPORT ZTEST_HEAP.
|
|
15
|
-
|
|
16
|
-
start-of-selection.
|
|
17
|
-
|
|
18
|
-
types:
|
|
19
|
-
begin of payload_ts,
|
|
20
|
-
i type i,
|
|
21
|
-
i_ref type ref to i,
|
|
22
|
-
end of payload_ts.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
data(payload) = value payload_ts(
|
|
26
|
-
i = 123
|
|
27
|
-
i_ref = new #( 123 )
|
|
28
|
-
).
|
|
29
|
-
|
|
30
|
-
data(json) = cl_sxml_string_writer=>create( if_sxml=>co_xt_json ).
|
|
31
|
-
|
|
32
|
-
call transformation id
|
|
33
|
-
source data = payload
|
|
34
|
-
result xml json.
|
|
35
|
-
|
|
36
|
-
cl_demo_output=>display_json( json = json->get_output( ) ).
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
the output it generates will be:
|
|
40
|
-
|
|
41
|
-
```json
|
|
42
|
-
{
|
|
43
|
-
"DATA":
|
|
44
|
-
{
|
|
45
|
-
"I":123,
|
|
46
|
-
"I_REF":
|
|
47
|
-
{
|
|
48
|
-
"%ref":"#d1"
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"%heap":
|
|
52
|
-
{
|
|
53
|
-
"d1":
|
|
54
|
-
{
|
|
55
|
-
"%type":"xsd:int",
|
|
56
|
-
"%val":123
|
|
57
|
-
}
|
|
58
|
-
}
|
|
10
|
+
```bash
|
|
11
|
+
npm install @abapify/asjson-parser
|
|
59
12
|
```
|
|
60
13
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
The code below
|
|
14
|
+
## Usage
|
|
64
15
|
|
|
65
16
|
```ts
|
|
66
17
|
import { parse } from '@abapify/asjson-parser';
|
|
67
|
-
const parser;
|
|
68
|
-
console.log(parse(json));
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
would print the object like this:
|
|
72
18
|
|
|
73
|
-
|
|
74
|
-
{
|
|
75
|
-
"DATA":
|
|
76
|
-
{
|
|
77
|
-
"I":123,
|
|
78
|
-
"I_REF": 123
|
|
79
|
-
}
|
|
19
|
+
const data = parse(asjsonPayload); // ABAP asJSON → plain JS object
|
|
80
20
|
```
|
|
81
21
|
|
|
82
|
-
##
|
|
83
|
-
|
|
84
|
-
- as a parser
|
|
22
|
+
## Features
|
|
85
23
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
console.log(parse(json));
|
|
89
|
-
```
|
|
24
|
+
- Parses SAP asJSON canonical format (including references and heap)
|
|
25
|
+
- Maps ABAP payloads to plain JavaScript objects
|
|
90
26
|
|
|
91
|
-
|
|
27
|
+
## Documentation
|
|
92
28
|
|
|
93
|
-
|
|
94
|
-
import { transform } from '@abapify/asjson-parser';
|
|
95
|
-
const object = JSON.parse(json);
|
|
96
|
-
console.log(transform(object));
|
|
97
|
-
```
|
|
29
|
+
**[adt-cli.netlify.app/sdk/packages/asjson-parser](https://adt-cli.netlify.app/sdk/packages/asjson-parser)**
|
|
98
30
|
|
|
99
|
-
|
|
31
|
+
---
|
|
100
32
|
|
|
101
|
-
|
|
102
|
-
import { proxy } from '@abapify/asjson-parser';
|
|
103
|
-
const object = JSON.parse(json);
|
|
104
|
-
console.log(proxy(object));
|
|
105
|
-
```
|
|
33
|
+
Part of [**abapify**](https://github.com/abapify/adt-cli) — open, typed tooling for SAP ABAP Development Tools (ADT): CLI, MCP server, and SDK.
|