<script src="https://rawgit.com/angular/bower-angular/master/angular.min.js"></script><script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div ng-app="JSONConverter">
<div ng-controller="JSONController" class="container">
<div class="row">
<div class="col-xs-6">
<h2>Paste JSON here</h2>
<p>The list on the right will change as soon as any new JSON is pasted.</p>
<form>
<textarea ng-model="rawJSON"
ng-change="processJSON(rawJSON)"
>
</textarea>
</form>
</div>
<div class="col-xs-6">
<h2>{{sampleTime()}}</h2>
<ul class="list-group">
<li ng-repeat="item in displayArray" class="list-group-item">
<p>PI Tag - {{item.pi_tag}}</p>
<p>Numeric Value - {{item.num_value}}</p>
</li>
</ul>
</div>
</div>
</div>
</div>
angular
.module('JSONConverter', [])
.controller('JSONController', JSONControllerFn);
function JSONControllerFn($scope){
$scope.rawData = {
"JOB": {
"SAMPLE": [{
"-SAMPLETIME": "18/09/2016 1100",
"SCHEME": [{
"ANALYTE": {
"-PI_TAG": "HV_FLOT_FEED_CNTLSOLID_S_pct",
"-NUMERICVALUE": "1.023800015449524"
}
}, {
"ANALYTE": {
"-ANALYTENAME": "DrySample",
"-NUMERICVALUE": "0.239999994635582"
}
}, {
"ANALYTE": {
"-PI_TAG": "HV_FLOT_FEED_CNTLSOLID_Ag_ppm",
"-NUMERICVALUE": "14.90999984741211"
}
}, {
"ANALYTE": {
"-PI_TAG": "HV_FLOT_TAIL_CNTLSOLID_Au_g/t",
"-NUMERICVALUE": "1.149999976158142"
}
}]
}, {
"-SAMPLETIME": "18/09/2016 1100",
"SCHEME": [{
"ANALYTE": {
"-PI_TAG": "HV_FLOT_TAIL_CNTLSOLID_S_pct",
"-NUMERICVALUE": "0.7418000102043152"
}
}, {
"ANALYTE": {
"-NUMERICVALUE": "0.2199999988079071"
}
}, {
"ANALYTE": {
"-PI_TAG": "HV_FLOT_TAIL_CNTLSOLID_Ag_ppm",
"-NUMERICVALUE": "3.674999713897705"
}
}, {
"ANALYTE": {
"-ANALYTENAME": "Au",
"-NUMERICVALUE": "0.1599999964237213"
}
}]
}, {
"-SAMPLETIME": "18/09/2016 1100",
"SCHEME": [{
"ANALYTE": {
"-PI_TAG": "HV_CONC_LEACH_FEED_CNTLSOLID_S_pct",
"-NUMERICVALUE": "7.076700210571289"
}
}, {
"ANALYTE": {
"-NUMERICVALUE": "0.2800000011920929"
}
}, {
"ANALYTE": {
"-PI_TAG": "HV_CONC_LEACH_FEED_CNTLSOLID_Ag_ppm",
"-NUMERICVALUE": "169.8899993896484"
}
}, {
"ANALYTE": {
"-PI_TAG": "HV_CONC_LEACH_FEED_CNTLSOLID_Au_g/t",
"-NUMERICVALUE": "10.96000003814697"
}
}]
}, {
"-SAMPLETIME": "18/09/2016 1100",
"SCHEME": [{
"ANALYTE": {
"-NUMERICVALUE": "0.2300000041723251"
}
}, {
"ANALYTE": {
"-PI_TAG": "HV_CONC_LEACH_TK1_CNTLSOLID_Ag_ppm",
"-NUMERICVALUE": "85.15499114990234"
}
}, {
"ANALYTE": {
"-PI_TAG": "HV_CONC_LEACH_TK1_CNTLSOLID_Au_g/t",
"-NUMERICVALUE": "544"
}
}]
}]
}
};
$scope.sample = $scope.rawData.JOB.SAMPLE;
$scope.sampleTime = function() {
return 'Sampletime - ' + $scope.sample[0]['-SAMPLETIME'];
}
$scope.ObjArray = function(){
//var sample = $scope.rawData.JOB.SAMPLE;
var ObjArr = [];
var obj;
angular.forEach($scope.rawData.JOB.SAMPLE, function(sample) {
var scheme = sample['SCHEME'];
angular.forEach(scheme, function(x) {
obj= {};
obj.pi_tag = x.ANALYTE['-PI_TAG'] || 'undefined';
obj.num_value = x.ANALYTE['-NUMERICVALUE'];
ObjArr.push(obj);
})
})
return ObjArr;
}
$scope.displayArray = $scope.ObjArray();
$scope.processJSON = function(data){
$scope.rawData = JSON.parse(data);
$scope.displayArray = $scope.ObjArray();
}
}
Output
300px
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |