mirror of
https://gitee.com/zyjblog/oatpp.git
synced 2024-12-22 22:16:37 +08:00
modify readme.md
This commit is contained in:
parent
301eda9444
commit
12439d84d7
64
README.md
64
README.md
@ -17,39 +17,9 @@ effective production level development. It's also light and has small memory foo
|
||||
- Follow us on **Twitter** for latest news. [@oatpp_io](https://twitter.com/oatpp_io)
|
||||
- Join community on **Reddit**. [r/oatpp](https://www.reddit.com/r/oatpp/)
|
||||
|
||||
## API - High Level Overview
|
||||
## High Level Overview
|
||||
|
||||
### Object Mapping
|
||||
|
||||
For more info see [Data Transfer Object (DTO)](https://oatpp.io/docs/components/dto/).
|
||||
|
||||
#### Declare DTO
|
||||
|
||||
```cpp
|
||||
class UserDto : public oatpp::data::mapping::type::Object {
|
||||
|
||||
DTO_INIT(UserDto, Object)
|
||||
|
||||
DTO_FIELD(Int64, id);
|
||||
DTO_FIELD(String, name);
|
||||
|
||||
};
|
||||
```
|
||||
|
||||
#### Serialize DTO Using ObjectMapper
|
||||
|
||||
```cpp
|
||||
using namespace oatpp::parser::json::mapping;
|
||||
|
||||
auto user = UserDto::createShared();
|
||||
user->id = 1;
|
||||
user->name = "Ivan";
|
||||
|
||||
auto objectMapper = ObjectMapper::createShared();
|
||||
auto json = objectMapper->writeToString(user);
|
||||
```
|
||||
|
||||
### API Controller - Request Mapping
|
||||
### API Controller And Request Mapping
|
||||
|
||||
For more info see [Api Controller](https://oatpp.io/docs/components/api-controller/)
|
||||
|
||||
@ -148,6 +118,36 @@ ENDPOINT("PUT", "/users/{userId}", putUser,
|
||||
}
|
||||
```
|
||||
|
||||
### Object Mapping
|
||||
|
||||
For more info see [Data Transfer Object (DTO)](https://oatpp.io/docs/components/dto/).
|
||||
|
||||
#### Declare DTO
|
||||
|
||||
```cpp
|
||||
class UserDto : public oatpp::data::mapping::type::Object {
|
||||
|
||||
DTO_INIT(UserDto, Object)
|
||||
|
||||
DTO_FIELD(Int64, id);
|
||||
DTO_FIELD(String, name);
|
||||
|
||||
};
|
||||
```
|
||||
|
||||
#### Serialize DTO Using ObjectMapper
|
||||
|
||||
```cpp
|
||||
using namespace oatpp::parser::json::mapping;
|
||||
|
||||
auto user = UserDto::createShared();
|
||||
user->id = 1;
|
||||
user->name = "Ivan";
|
||||
|
||||
auto objectMapper = ObjectMapper::createShared();
|
||||
auto json = objectMapper->writeToString(user);
|
||||
```
|
||||
|
||||
### Read Next
|
||||
|
||||
- [Well Structured Project](https://oatpp.io/docs/start/step-by-step/#well-structured-project)
|
||||
|
Loading…
Reference in New Issue
Block a user