Comments (5)
Good idea, will do (but with old syntax, because the class should be downward compatible down to 7.02.
from zjson.
Hi Sérgio,
good idea, thank you for that.
Looks like the /UI2/CL_JSON has been enhanced a lot in 7.50. There was no constructor in 7.40.
(but as always: cannot give any promisses when it will be done. Feel free to contribute)
Cheers, Uwe
from zjson.
Hi Sérgio,
I've implemented the changes. Can you please test? (Branch "issue_27")
Test ABAP -> JSON:
DATA: BEGIN OF local_test,
field_number1 TYPE string VALUE '111',
field_number2 TYPE string VALUE '222',
field_number3 TYPE string VALUE '333',
END OF local_test.
*
DATA(json) = zcl_json_document=>create_with_data(
data = local_test
name_mappings = VALUE #(
(
abap_name = 'field_number2'
json_name = 'ThisIsATheJSONFieldName'
)
(
abap_name = 'field_number3'
json_name = 'FieldNameThree'
)
)
)->get_json( ).
cl_demo_output=>display_json( json ).
Result:
{
"field_number1":"111",
"ThisIsATheJSONFieldName":"222",
"FieldNameThree":"333"
}
Test JSON -> ABAP
DATA: BEGIN OF local_test,
field_number1 TYPE string VALUE '111',
field_number2 TYPE string VALUE '222',
field_number3 TYPE string VALUE '333',
END OF local_test.
DATA json type string.
json = '{' &&
' "field_number1":"111",' &&
' "ThisIsATheJSONFieldName":"222",' &&
' "FieldNameThree":"333"' &&
'}'.
DATA(json_doc) = zcl_json_document=>create_with_json(
json = json
name_mappings = VALUE #(
(
abap_name = 'field_number2'
json_name = 'ThisIsATheJSONFieldName'
)
(
abap_name = 'field_number3'
json_name = 'FieldNameThree'
)
)
).
TRY.
json_doc->get_data( IMPORTING data = local_test ).
cl_demo_output=>display( local_test ).
CATCH zcx_json_document.
ENDTRY.
Result:
FIELD_NUMBER1 FIELD_NUMBER2 FIELD_NUMBER3
111 222 333
Cheers, Uwe
from zjson.
Hello @se38 ,
Thanks a lot!
Did some tests and all looks good.
The only issue I found is if I send an abap_name with capital letters.. since the internals of zjson is converting everything to lower case, name_mapping table must be sent in lower case also.
Possible solution could be:
`METHOD set_name_mappings.
me->name_mappings = VALUE #( FOR <name> IN name_mappings (
abap_name = |{ <name>-abap_name CASE = LOWER }|
json_name = |{ <name>-json_name CASE = LOWER }| ) ).
ENDMETHOD.`
What do you think?
from zjson.
Implemented lower case ABAP names and merged with Master branch
from zjson.
Related Issues (20)
- Set new version number
- Component name "DATA" breaks CREATE_WITH_DATA
- wdr_simple_name_value_list not present on 7.00 systems HOT 3
- APPEND_DATA: malformed JSON
- Escape Slash
- ZJSON install issue HOT 14
- ZJSON examples in ABAP HOT 2
- License HOT 3
- export ZIP error HOT 1
- Respect hyphen or CamelCase (JSON -> Data)
- It takes more than 10 minutes to call method DUMPS. HOT 2
- Performance Problem on Large Json HOT 6
- Fieldname mapping with mapping JSON or XSLT
- Syntaxe Issue when a value begins with : HOT 4
- zabapgit error when pulling objects (see scrshot detailing error attached) HOT 7
- Error in Hana DB only HOT 3
- abap <-> json name mapping not working when converting json to abap table HOT 6
- Russian char HOT 2
- FIND_INFINITE_LOOP + while creating the JSON HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zjson.