Commit 7f39ea93 authored by Floyd Hightower's avatar Floyd Hightower

Adding ability to turn bracketPathNotation on and off

Fixes #7
parent a574f1ba
......@@ -2,5 +2,9 @@
<div class="reveal" id="inputModal" data-reveal>
<textarea [(ngModel)]="rawInput" rows="30" placeholder="Enter some json data..." (keyup)="invalidate()"></textarea>
<input type="checkbox" [(ngModel)]="useBracketPathNotation"> Produce mappings using bracket notation
<br>
<button class="button" (click)="submitJson()">Submit</button> &nbsp;<div *ngIf="data.validationStatus === 'Validated'" style="display: inline;"><p style="color: green; display: inline;">{{ data.validationStatus }}</p></div><div *ngIf="data.validationStatus === 'Unvalidated'" style="display: inline;"><p style="color: yellow; background-color: darkgrey; display: inline;">{{ data.validationStatus }}</p></div><div *ngIf="data.validationStatus !== 'Unvalidated' && data.validationStatus !== 'Validated'" style="display: inline;"><p style="color: red; display: inline;">{{ data.validationStatus }}</p></div>
</div>
......@@ -6,15 +6,21 @@ import { DataService } from '../../services/data.service';
declare var $:any;
function parseJson(content: string) {
function parseJson(content: string, useBracketNotation: boolean) {
// get the response data
var rawData = content.replace(/'/g, '"');
var jsonData = JSON.parse(rawData);
// parse and output the content
$('#json-renderer').jsonPathPicker(jsonData, {
pathQuotesType: 'double',
pathNotation: 'brackets'
});
if (useBracketNotation) {
$('#json-renderer').jsonPathPicker(jsonData, {
pathQuotesType: 'double',
pathNotation: 'brackets'
});
} else {
$('#json-renderer').jsonPathPicker(jsonData, {
pathQuotesType: 'double'
});
}
}
@Component({
......@@ -24,6 +30,7 @@ function parseJson(content: string) {
})
export class JsonInputComponent implements OnInit {
rawInput: string = '';
useBracketPathNotation: boolean = true;
constructor(
private data: DataService
......@@ -38,7 +45,7 @@ export class JsonInputComponent implements OnInit {
this.data.jsonData = JSON.parse(this.rawInput);
this.data.validationStatus = 'Validated';
this.rawInput = JSON.stringify(this.data.jsonData, null, 4);
parseJson(this.rawInput);
parseJson(this.rawInput, this.useBracketPathNotation);
window.setTimeout(function() {
$('#inputModal').foundation('close');
$('.jqueryUpdateButton').each(function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment