-
Notifications
You must be signed in to change notification settings - Fork 47
/
property-to-json-converter.html
209 lines (198 loc) · 10.9 KB
/
property-to-json-converter.html
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
---
title: Property File Data To JSON Format Converter | Developer Tools
layout: post
---
<html>
<head>
<!-- Meta tags common for website -->
{% include common-meta %}
<title>{{ page.title }}</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<meta name="description" content="This is easy to use open source tool to convert JSON data to property file entry format. " />
<meta name="keywords" content="online,tool,json,property,properties,convert,converter,web,opensource" />
<!-- CSS for the site theme -->
{% include theme-css %}
<!-- Annoying IE fixes -->
{% include ie-fixes %}
</head>
<body class="hold-transition skin-green sidebar-mini">
<!-- Site wrapper -->
<div class="wrapper">
<!-- header tag from theme -->
{% include theme-header %}
<!-- Sidebar for the whole website -->
{% include theme-sidebar %}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Main content -->
<section class="content">
<div class="row">
<!-- left column -->
<div class="col-md-6">
<div class="box box-success">
<div class="box-header with-border">
<h1 class="box-title">Convert Property Format Data To JSON</h1>
</div>
<!-- /.box-header -->
<!-- form start -->
<div class="box-body">
<form role="form">
<div class="form-group">
<label for="csv">Property File Data</label>
<textarea class="form-control" rows="10" id="property" placeholder="Enter your Property File Data here" autofocus></textarea>
<div style="display:hidden;">
<div id="hidden" style="display:hidden;"></div>
</div>
</div>
</form>
</div>
<!-- /.box-body -->
<div class="box-footer">
<div class="row">
<div class="col-xs-3">
<button type="button" class="btn btn-info" id="generate">Convert to JSON</button>
</div>
</div>
</div>
<!-- /.box-footer -->
</div>
</div>
<div class="col-md-6">
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Copy Your JSON Data From Here</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<div class="form-group">
<label for="json">JSON Format Converted Data</label>
<textarea class="form-control" id="jsonValues" rows="10"></textarea>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="content">
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">About Property to JSON Converter Tool</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<img class="img-responsive" src="images/property-to-json.png" alt="Property to JSON format converter tool" title="Property to JSON format converter tool">
<p>This is a free online tool to convert a property file format to JSON formatted data to. This can be useful tool for converting all property file entries to a single JSON document. You can convert any <code>KEY = VALUE</code> format data to JSON data using this tool.</p>
<p>This tool can take care of nested property conversion to nested JSON objects by name matching.</p>
</div>
<!-- /.box-body -->
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">What is a JSON Format?</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>JSON (JavaScript Object Notation) is a popular format used to transfer data between applications. It is very common object format in web applications. JavaScript applications do not require any speciall handling for this type of data since its is already an object of javascript format. </p>
</div>
<!-- /.box-body -->
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">What is a Property format?</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>Property files are common way to provide KEY, VALUE pair configuration for programs. </p>
<p>Many programming langugages use configuration files that have simple format that stores each <code>KEY = VALUE</code> pair in new line.</p>
</div>
<!-- /.box-body -->
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">What is a Property File format convention?</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>A commonly accepted propeerty file convention is to use dot <code>(.)</code>or underscore <code>(_)</code> as a separator in keys. </p>
<p>e.g. dot <code>(.)</code> as a separator</p>
<code>Persons.person.name = John</code>
<code>Persons.person.age = 30</code>
<code>Persons.person.city = SFO</code>
<p>Or underscore <code>(_)</code> as a separator</p>
<code>Persons_person_name = John</code>
<code>Persons_person_age = 30</code>
<code>Persons_person_city = SFO</code>
<p>In case your property file does not follow this convention you may need to specify the separator for successful conversion to JSON format. </p>
</div>
<!-- /.box-body -->
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Why Convert From Property File to JSON Object format?</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>JSON Objects are easy to read using JavaScript and can also be easily consumed by many REST based services. This tool can help data conversion easy for property file to JSON format on one click. </p>
</div>
<!-- /.box-body -->
</div>
<div class="box box-success">
<div class="box-header with-border">
<h3 class="box-title">Why Do We Need A Property File to a JSON Object Format Converter Online?</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<p>The online converter is a good help for property file format data to JSON format. This tool can be handy since you just need to paste the property file data in the input field and hit convert button. </p>
<p>The same task can be done manually, however it can be cumbersome. This tool can save you some time and follow a consistent pattern to create a valid JSON document from well formatted property file.</p>
<p>You just need to copy and paste the property file content into this tool and get the JSON format data.</p>
<p>JSON Objects are easy to read in JavaScript, you can easily convert data in a property file to a JavaScript Object and access it easily in Node.js , Express.js, React.js anre more JavaScript based applications and frameworks.</p>
<p>Many times, we do not want to use property files. In that case this tool can help you convert entire property file into a JSON document.</p>
<p>The tool follows a simple naming convention and can identify nested property values based on name matching (case-sensitive). </p>
</div>
<!-- /.box-body -->
</div>
</section>
{% include addthis %}
</div>
<!-- /.content-wrapper -->
{% include theme-footer %}
</div>
<!-- ./wrapper -->
{% include theme-bottom-js %}
</body>
<script src="plugins/selectOnFocus/jquery.selectOnFocus.min.js"></script>
<script src="javascripts/property2json.js"></script>
<script>
$(document).ready(function() {
$("#json").selectOnFocus();
$("#propertyValues").selectOnFocus();
$('#converters-category').addClass('active');
$("#generate").click(function() {
var start = performance.now();
$("#generate").html('Generating...Please Wait...');
$("#generate").prop('disabled', true);
var text = $("#property").val();
let json = {};
if(text) {
try {
let lines = text.split('\n') || [];
lines = lines.filter(line=>(line && line.length));
lines.forEach(line => {
const pair = line.split('=');
const value = pair[1];
var propeertyEntries = pair[0].split('.');
json = property2json(propeertyEntries,value,json);
});
}
catch(error) {
console.log(error);
}
$("#jsonValues").val(JSON.stringify(json));
}
$("#generate").prop('disabled', false);
$("#generate").html('Convert to JSON');
});
});
</script>
</html>