mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
fix: json to java typecheck
This commit is contained in:
1 parent
0c2a2e982e
commit
7720721278
1 file changed
+3
-5
@@ -6,19 +6,17 @@ export function convert(className: string, data: string | null) {
|
||||
if (data === null) {
|
||||
return '';
|
||||
}
|
||||
if (typeof data === 'string') {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
const obj = JSON.parse(data);
|
||||
if (className === '') {
|
||||
className = 'Result';
|
||||
}
|
||||
const keys = Object.keys(data);
|
||||
const keys = Object.keys(obj);
|
||||
const objects: { [key: string]: any } = {};
|
||||
className = capitalizeFirstLetter(className);
|
||||
let result = `public class ${className} {\n`;
|
||||
for (const i in keys) {
|
||||
const key = keys[i];
|
||||
const value = data[key];
|
||||
const value = obj[key];
|
||||
let type = typeof value as string;
|
||||
if (Array.isArray(value)) {
|
||||
const typeName = capitalizeFirstLetter(fixListClass(key));
|
||||
|
||||
Reference in new issue
Block a user