Skip to content

Commit

Permalink
Merge pull request josdejong#164 from yanivefraim/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Feb 13, 2015
2 parents abc3ac3 + 7bb6b6d commit 1a5ea41
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
12 changes: 11 additions & 1 deletion jsoneditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* @author Jos de Jong, <[email protected]>
* @version 3.2.0
* @date 2015-01-25
* @date 2015-02-13
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
Expand Down Expand Up @@ -1481,6 +1481,16 @@ return /******/ (function(modules) { // webpackBootstrap
return $1 + '"' + $2 + '"' + $3;
});

jsonString = jsonString.replace(/\/\*(.|[\r\n])*?\*\//g,'');//Remove all code comments

//If JSON starts with a function (Carachters/digist/"_-"), remove this function.
//This is usefull for "stripping" JSONP objects to become JSON
//For example: function_12321321 ( [{"a":"b"}] ); => [{"a":"b"}]
var match = jsonString.match(/^\s*[\dA-z_$]+\s*\(([\s\S]*)\)\s*;?\s*$/);
if (match) {
var jsonString = match[1];
}

return jsonString;
};

Expand Down
2 changes: 1 addition & 1 deletion jsoneditor.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions jsoneditor.min.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ define(function () {
return $1 + '"' + $2 + '"' + $3;
});

jsonString = jsonString.replace(/\/\*(.|[\r\n])*?\*\//g,'');//Remove all code comments

//If JSON starts with a function (Carachters/digist/"_-"), remove this function.
//This is usefull for "stripping" JSONP objects to become JSON
//For example: function_12321321 ( [{"a":"b"}] ); => [{"a":"b"}]
var match = jsonString.match(/^\s*[\dA-z_$]+\s*\(([\s\S]*)\)\s*;?\s*$/);
if (match) {
var jsonString = match[1];
}

return jsonString;
};

Expand Down

0 comments on commit 1a5ea41

Please sign in to comment.