https://github.com/yah01/cybuf-java
a java package for marshal & unmarshal cybuf format data
https://github.com/yah01/cybuf-java
Last synced: over 1 year ago
JSON representation
a java package for marshal & unmarshal cybuf format data
- Host: GitHub
- URL: https://github.com/yah01/cybuf-java
- Owner: yah01
- License: mit
- Created: 2020-04-17T12:44:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-06-17T03:29:08.000Z (about 4 years ago)
- Last Synced: 2025-02-02T01:10:04.424Z (over 1 year ago)
- Language: Java
- Size: 85.9 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cybuf-java
a java package for marshal & unmarshal cybuf format data
### usage
* cybuf.toCybufString(Object)
* input:a java object ;
* output:a cybuf format String;
* cybuf.parseObject(String)
* input:a cybuf format String;
* output:a cybufObject;
* cybuf.parseObject(String,javaBean.class)
* input:a cybuf format String ,object class type;
* output:a javaBean instance;
* ps:your class must implement setters and getters;
### example
```java
public class School
{
String name;
Integer age;
Double area;
Boolean open;
ArrayList teachers;
Person[] students;
Person header;
Object nil;
/*
setters and getters
*/
}
```
```java
String result = Cybuf.toCybufString(school,false,true, SerializerConfig.NEWLINE);
System.out.println(result);
//you will get result
/*
{
area: 1000.34
nil: nil
teachers: [
{
name: "tcg"
ok: true
age: 100
height: 173.5
}
{
name: "tcg"
ok: true
age: 100
height: 173.5
}
]
name: "ECNU"
header: {
name: "tcg"
ok: true
age: 100
height: 173.5
}
students: [
{
name: "tcg"
ok: true
age: 100
height: 173.5
}
{
name: "tcg"
ok: true
age: 100
height: 173.5
}
]
age: 100
open: true
}
*/
```
```java
School s1 = Cybuf.parseObject(result,School.class);
//you will get a School instance s1
```