Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serialize timestampl #896

Merged
merged 3 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/json/#ui2#cl_json.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,11 @@ CLASS /ui2/cl_json IMPLEMENTATION.
OR lo_type->absolute_name = `\TYPE=TIMESTAMPL` ).
IF data IS INITIAL.
r_json = |""|.
ELSE.
ELSEIF lo_type->absolute_name = `\TYPE=TIMESTAMP`.
r_json = |"{ data TIMESTAMP = ISO }.0000000Z"|.
ELSE.
r_json = |"{ data TIMESTAMP = ISO }Z"|.
REPLACE ',' IN r_json WITH '.'.
ENDIF.
ELSE.
r_json = |{ data }|.
Expand Down
15 changes: 15 additions & 0 deletions src/json/#ui2#cl_json.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ CLASS ltcl_serialize DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT F
METHODS serialize_timestamp_iso FOR TESTING RAISING cx_static_check.
METHODS serialize_timestamp_iso_empty FOR TESTING RAISING cx_static_check.
METHODS serialize_timestampl_iso_empty FOR TESTING RAISING cx_static_check.
METHODS serialize_timestampl_iso FOR TESTING RAISING cx_static_check.
METHODS camel_case FOR TESTING RAISING cx_static_check.
METHODS character10 FOR TESTING RAISING cx_static_check.
METHODS character10_value FOR TESTING RAISING cx_static_check.
Expand All @@ -664,6 +665,20 @@ ENDCLASS.

CLASS ltcl_serialize IMPLEMENTATION.

METHOD serialize_timestampl_iso.
DATA: BEGIN OF foo,
ts TYPE timestampl,
END OF foo.
DATA lv_json TYPE string.
GET TIME STAMP FIELD foo-ts.
lv_json = /ui2/cl_json=>serialize(
data = foo
ts_as_iso8601 = abap_true ).
cl_abap_unit_assert=>assert_text_matches(
text = lv_json
pattern = '\{"TS":"\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d\.\d\d\d\d\d\d\dZ"\}' ).
ENDMETHOD.

METHOD serialize_empty_xstring.
DATA: BEGIN OF is_metadata,
foo TYPE xstring,
Expand Down