Fixed #111: accept JavaScript objects as input, and turn them into valid JSON
This commit is contained in:
parent
bb53153d3b
commit
c72ea9b6e1
|
@ -3,6 +3,12 @@
|
||||||
https://github.com/josdejong/jsoneditor
|
https://github.com/josdejong/jsoneditor
|
||||||
|
|
||||||
|
|
||||||
|
## not yet released, version 3.1.0
|
||||||
|
|
||||||
|
- JSONEditor now accepts JavaScript objects as input, and can turn them into
|
||||||
|
valid JSON. For example `{a:2,b:'str'}` can be turned into `{"a":2,"b":"str"}`.
|
||||||
|
|
||||||
|
|
||||||
## 2014-05-31, version 3.0.0
|
## 2014-05-31, version 3.0.0
|
||||||
|
|
||||||
- Large code reorganization.
|
- Large code reorganization.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "jsoneditor",
|
"name": "jsoneditor",
|
||||||
"version": "3.0.0",
|
"version": "3.1.0-SNAPSHOT",
|
||||||
"description": "A web-based tool to view, edit and format JSON",
|
"description": "A web-based tool to view, edit and format JSON",
|
||||||
"tags": [
|
"tags": [
|
||||||
"json",
|
"json",
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
* Copyright (c) 2011-2014 Jos de Jong, http://jsoneditoronline.org
|
* Copyright (c) 2011-2014 Jos de Jong, http://jsoneditoronline.org
|
||||||
*
|
*
|
||||||
* @author Jos de Jong, <wjosdejong@gmail.com>
|
* @author Jos de Jong, <wjosdejong@gmail.com>
|
||||||
* @version 3.0.0
|
* @version 3.1.0-SNAPSHOT
|
||||||
* @date 2014-05-31
|
* @date 2014-07-26
|
||||||
*/
|
*/
|
||||||
(function webpackUniversalModuleDefinition(root, factory) {
|
(function webpackUniversalModuleDefinition(root, factory) {
|
||||||
if(typeof exports === 'object' && typeof module === 'object')
|
if(typeof exports === 'object' && typeof module === 'object')
|
||||||
|
@ -37,12 +37,12 @@
|
||||||
root["JSONEditor"] = factory();
|
root["JSONEditor"] = factory();
|
||||||
})(this, function() {
|
})(this, function() {
|
||||||
return /******/ (function(modules) { // webpackBootstrap
|
return /******/ (function(modules) { // webpackBootstrap
|
||||||
/******/
|
|
||||||
/******/ // The module cache
|
/******/ // The module cache
|
||||||
/******/ var installedModules = {};
|
/******/ var installedModules = {};
|
||||||
/******/
|
/******/
|
||||||
/******/ // The require function
|
/******/ // The require function
|
||||||
/******/ function __webpack_require__(moduleId) {
|
/******/ function __webpack_require__(moduleId) {
|
||||||
|
/******/
|
||||||
/******/ // Check if module is in cache
|
/******/ // Check if module is in cache
|
||||||
/******/ if(installedModules[moduleId])
|
/******/ if(installedModules[moduleId])
|
||||||
/******/ return installedModules[moduleId].exports;
|
/******/ return installedModules[moduleId].exports;
|
||||||
|
@ -74,7 +74,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
/******/ // __webpack_public_path__
|
/******/ // __webpack_public_path__
|
||||||
/******/ __webpack_require__.p = "";
|
/******/ __webpack_require__.p = "";
|
||||||
/******/
|
/******/
|
||||||
/******/
|
|
||||||
/******/ // Load entry module and return exports
|
/******/ // Load entry module and return exports
|
||||||
/******/ return __webpack_require__(0);
|
/******/ return __webpack_require__(0);
|
||||||
/******/ })
|
/******/ })
|
||||||
|
@ -1386,9 +1385,19 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
return JSON.parse(jsonString);
|
return JSON.parse(jsonString);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
// try to throw a more detailed error message using validate
|
// try to load as JavaScript instead of JSON (like "{a: 2}" instead of "{"a": 2}"
|
||||||
util.validate(jsonString);
|
try {
|
||||||
throw err;
|
return eval('(' + jsonString + ')');
|
||||||
|
}
|
||||||
|
catch(err2) {
|
||||||
|
// ok no luck loading as JavaScript
|
||||||
|
|
||||||
|
// try to throw a more detailed error message using validate
|
||||||
|
util.validate(jsonString);
|
||||||
|
|
||||||
|
// rethrow the original error
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "jsoneditor",
|
"name": "jsoneditor",
|
||||||
"version": "3.0.0",
|
"version": "3.1.0-SNAPSHOT",
|
||||||
"main": "jsoneditor.js",
|
"main": "jsoneditor.js",
|
||||||
"description": "A web-based tool to view, edit and format JSON",
|
"description": "A web-based tool to view, edit and format JSON",
|
||||||
"tags": [
|
"tags": [
|
||||||
|
|
|
@ -13,9 +13,19 @@ define(function () {
|
||||||
return JSON.parse(jsonString);
|
return JSON.parse(jsonString);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
// try to throw a more detailed error message using validate
|
// try to load as JavaScript instead of JSON (like "{a: 2}" instead of "{"a": 2}"
|
||||||
util.validate(jsonString);
|
try {
|
||||||
throw err;
|
return eval('(' + jsonString + ')');
|
||||||
|
}
|
||||||
|
catch(err2) {
|
||||||
|
// ok no luck loading as JavaScript
|
||||||
|
|
||||||
|
// try to throw a more detailed error message using validate
|
||||||
|
util.validate(jsonString);
|
||||||
|
|
||||||
|
// rethrow the original error
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue