Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/framework/zcl_mcp_jsonrpc.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ CLASS zcl_mcp_jsonrpc IMPLEMENTATION.
result = array_json->stringify( ).
ENDMETHOD.


METHOD serialize_request.
DATA json_obj TYPE REF TO zif_mcp_ajson.
DATA params_node_type TYPE zif_mcp_ajson_types=>ty_node_type.
Expand Down Expand Up @@ -336,18 +335,19 @@ CLASS zcl_mcp_jsonrpc IMPLEMENTATION.
json_obj->set_string( iv_path = '/id'
iv_val = request-id ).
ENDIF.
CATCH zcx_mcp_ajson_error.
CATCH cx_sy_conversion_no_number.
" Not a number, use as string
json_obj->set_string( iv_path = '/id'
iv_val = request-id ).
CATCH zcx_mcp_ajson_error.
" Handle JSON operation error
ENDTRY.
ENDIF.

" Convert to string
result = json_obj->stringify( ).
ENDMETHOD.


METHOD serialize_response.
DATA json_obj TYPE REF TO zif_mcp_ajson.
DATA result_json TYPE string.
Expand Down Expand Up @@ -396,21 +396,27 @@ CLASS zcl_mcp_jsonrpc IMPLEMENTATION.

" Add ID with correct type
IF response-id IS NOT INITIAL.
" Add ID with correct type if present
TRY.

temp2 = response-id.

number = temp2.
" Only treat as number if exact string representation matches
IF response-id = |{ number }|.
json_obj->set_integer( iv_path = '/id'
iv_val = number ).
ELSE.
" Not an exact number, treat as string
json_obj->set_string( iv_path = '/id'
iv_val = response-id ).
ENDIF.
CATCH zcx_mcp_ajson_error.
CATCH cx_sy_conversion_no_number.
" Not a number, use as string
json_obj->set_string( iv_path = '/id'
iv_val = response-id ).
CATCH zcx_mcp_ajson_error.
" Handle JSON operation error
ENDTRY.
ELSE.
" Null ID
Expand Down