-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodelOC.html
More file actions
executable file
·49 lines (48 loc) · 1.32 KB
/
Copy pathmodelOC.html
File metadata and controls
executable file
·49 lines (48 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<html>
<head>
<script>
window.onload = function () {
var oBtn = document.getElementById('createBtn');
oBtn.onclick = function () {
var textarea = document.getElementById('inputText');
var text = textarea.value
text = text.replace(/[ ]+/g, function(){
return '';
});
var reg = ',\n';
var arr = text.split(reg);
var resultStr = "";
for (var i = 0; i < arr.length; i++) {
var eArr = arr[i].split(/\":/g);
var left = eArr[0].replace(/\"/g,function(){
return '';
});
var right = eArr[1];
var type = "@property(nonatomic,strong)NSString *";
if (/^\d+$/.test(right)){
type = "@property(nonatomic,assign)int ";
}else if (/^\d*\.\d*$/.test(right)){
type = "@property(nonatomic,assign)double ";
}else if (/^{/.test(right)){
type = "@property(nonatomic,strong)NSDictionary *";
}else if (/^[true]|[false]$/.test(right)){
type = "@property(nonatomic,assign)BOOL ";
}else if (/^\[/.test(right)){
type = "@property(nonatomic,strong)NSArray *";
}
var eResultStr = type + left + ";\n";
resultStr += eResultStr;
};
textarea.value = resultStr;
};
}
</script>
</head>
<body>
<input type="button" value="create" id="createBtn"></input>
</br>
<textarea name="inputText" style='width:600px;height:600px' id='inputText'>"user_id" : "1",
"name":"ly",
"c_la":30.9</textarea>
</body>
</html>