Commit Graph

47 Commits

Author SHA1 Message Date
jos 4f433cb6a9 A fix in repairing line-separated json 2020-03-25 12:18:41 +01:00
jos fd0db5dc73 Implement support for repairing line separate JSON 2020-03-25 12:11:33 +01:00
jos 582645df70 Fix replacing Python constants in arrays 2020-02-16 10:11:12 +01:00
jos dcc66d5d81 Fixed #906: Implemented turning Python objects containing `True`, `False` and `None` into valid JSON using repair 2020-02-15 20:21:38 +01:00
jos 10a48ca7b2 Fix lint issues 2019-12-28 17:17:27 +01:00
jos 275fcc8fee Changed the file size reported in `preview` mode to `KB` and `MB` 2019-12-28 17:12:56 +01:00
jos 03fa90bd71 Revert using field names to determine whether a value is a timestamp (see #847, #856) 2019-12-11 11:51:48 +01:00
Meir Rotstein 266eeec21a onValidationError option (#854)
* provide onValidationError callback

* linter fixes

* docu fixes

* textmode - invoke callback also when no errors
This to cover situation of changes that fixes validations

* fixed cautom validation example
2019-12-01 16:21:16 +01:00
jos 51410c363f More improvements in the built-in `isTimestamp` function (see #847) 2019-11-27 15:45:48 +01:00
jos 39dfc41100 Improve `timestampTag` API (see #847) 2019-11-27 15:28:50 +01:00
jos a60a1125ea Reverted solution for #794 due to undesirable side effects 2019-09-17 20:20:40 +02:00
jos 8554789aa7 Fix #794: fix discrepancy between valid JSON numbers and valid JavaScript numbers 2019-09-15 11:55:15 +02:00
jos b79885471e A few more files refactored to ES modules 2019-08-31 11:21:29 +02:00
jos e67fa19375 Run lebab on test folder: convert let/const and arrow functions 2019-08-28 13:43:06 +02:00
jos a5d6b8a65b Set up code style linting with standardjs 2019-08-28 13:21:14 +02:00
jos 964fe3e06d Fixed #761: JSON schema errors not rendered in the gutter for mode `code` when the path contained a property with a forward slash 2019-08-25 20:43:21 +02:00
jos 14cdd0e61b Fix using arrow function and const 2019-07-28 11:45:43 +02:00
jos 3f182a1f04 Repair button is now capable of turning MongoDB documents into valid JSON 2019-07-27 14:16:59 +02:00
jos cec16b9de1 Rename `util.sanitize` to `util.repair` 2019-07-27 13:13:02 +02:00
jos df952ac61d Replace deprecated `assert.equal` with `assert.strictEqual` 2019-07-27 13:08:02 +02:00
jos 9ed18da7b6 Create util function `limitCharacters`, tweak limiting of preview texts 2019-07-03 11:54:00 +02:00
jos 1e1ee3463c Implemented `preview` mode (WIP) 2019-06-26 17:24:09 +02:00
jos 797541cd6b Make `getChildPaths` json pointer compliant 2019-06-19 12:46:50 +02:00
jos 7311e78b53 Implemented `transform` modal for modes `code` and `text` 2019-06-19 11:57:28 +02:00
jos 74b816a554 Implemented sort button in code/text mode 2019-06-19 11:16:30 +02:00
jos 70b7e7914b Fixed #663 and #682: JSONEditor not being able to handle JSON schema validation errors when the root of the document is an Array 2019-04-10 12:23:13 +02:00
jos b38816a88b Merge branch 'duplicate_key_errors_take2' into develop
# Conflicts:
#	src/js/util.js
2019-04-03 14:56:39 +02:00
jos 801921867d Improve detection of value type in transform modal 2019-03-31 19:51:12 +02:00
jos 00baaacacc Disable having duplicate nodes (except whilst typing) 2019-03-30 13:35:51 +01:00
Adam Vigneaux 09ab92017c Fix JSON path parsing for array indices (#679)
* Switch JSON path tests to strict equality

The tests for `stringifyPath` and `parsePath` were using
[`assert.deepEqual`](https://nodejs.org/api/assert.html#assert_assert_deepequal_actual_expected_message),
which was causing the tests to pass when they should not have. Beyond
that, the `deepEqual` method is deprecated. The suggested replacement is
[`assert.deepStrictEqual`](https://nodejs.org/api/assert.html#assert_assert_deepstrictequal_actual_expected_message),
which causes the tests to fail where they should.

The difference between the two methods is the different between `==` and
`===`. `deepEqual` would coerce the input `"2"` to `2`, so the test was
passing even though the output was of the wrong type (string instead of
number).

* Coerce numeric indices to numbers in parsePath

This fixes a regression introduced in
3e7e1cebfd.
2019-03-28 19:49:36 +01:00
tobiasfriden 4763bdf293 Fixed using hyphens in the path of custom validation errors (#665)
* Fixed a bug where using hyphens in the path for custom validatons error didn't work

* Added closing bracket check and unit tests

* Automatically add brackets when path component contains hyphens

* use regexp to check if dot notation is safe
2019-03-21 21:27:17 +01:00
jos 3e7e1cebfd Fixed #676: JSON Paths containing array properties with a `]` not parsed correctly 2019-03-20 17:34:39 +01:00
Adam Vigneaux c79bea4eb8 Display schema defaults inline next to Nodes (#666)
* Display schema defaults inline next to Nodes

* Improve usability of schema default display

- When value is default, make it bold and set a tooltip
- When value is not default, display the default next to the value
- When value is default and is a select, show "Default" next to it
- Lighten the color of green used for values
  This increases the contrast between normal values and default values.

* Remove styling when value is the same as the schema default

This styling may have been confusing for some users and may not have
been applicable to all situations.

* Apply is-default and is-not-default classes to values

This allows the user to supply custom styling for these states.

To set styles for values that match the default value in the schema, use
the class `.jsoneditor-is-default`.

To set styles for values that _do not_ match the default value in the
schema, use the class `.jsoneditor-is-not-default`.

* Remove extra newline after schema examples in tooltip

* Move schema default display from inline to tooltip

This presents less opportunity for user confusion and is likely to be
more widely applicable.

* Add examples of schema metadata display

* Add documentation on styling
2019-03-17 15:39:00 +01:00
Adam Vigneaux 803563003c
Show examples from schema in field tooltip 2019-03-04 16:10:30 -05:00
Adam Vigneaux dc357061a7
Add schema-based tooltip to field names
Using the `title` and `description` properties from the schema, create
and set a tooltip on each field name. When the user hovers over a field
name, it will show the applicable information: title, description, both,
or neither, depending on what data is present in the schema.
2019-02-08 09:31:28 -05:00
jos 6551701153 Fixed #610: JSON Repair now removes trailing commas 2018-12-06 20:15:14 +01:00
Meir Rotstein f04eff7b4e unit test for getIndexForPosition() 2018-01-24 21:41:36 +02:00
jos 4875288cb7 Implemented repairing JSON objects containing special white space characters like non-breaking space 2017-11-14 21:59:23 +01:00
jos cba5659e78 Implemented repairing JSON objects containing left and right single and double quotes 2017-11-14 21:18:49 +01:00
jos 524d00e15e Fixed a bug in the sanitizer 2017-07-13 21:01:52 +02:00
Stephen Thompson 48408f4ded Fix https://github.com/josdejong/jsoneditor/issues/314
The JSON path parsing code assumes that string keys within square brackets in JSON paths will be valid, parseable JSON.

However, the ajv library on which this project depends emits string keys in single quotes.

For example, ajv can emit .foo['bar'], which will ultimately end up with a call to JSON.parse("'bar'"). This causes the "Unexpected token ' in JSON at position 0" error thrown from JSON.parse.

 Since ajv shouldn't need to change and since this utility is gone in the next branch, this fix checks for ajv-formatted string keys and patches them to double-quoted strings before calling JSON.parse. This is the narrowest fix for the problem.
2016-09-22 18:06:22 -04:00
jos 8f7b656c3c Extended `util.parsePath` with support for all '*' 2016-04-04 21:28:23 +02:00
jos 8ec471b6dc Improvements in sanitizing invalid JSON 2016-01-16 14:49:04 +01:00
jos 4b5ac7434f Parent nodes now display an error when a child node is invalid 2016-01-11 17:06:12 +01:00
jos 75372fa3d7 More unit tests and a refinement of the regexp to remove JSONP encapsulation 2015-02-28 17:03:40 +01:00
jos b94b87c66b Fixed bugs in the JSON sanitizer, no longer manipulating comments or JSON-like structures inside strings. 2015-02-28 16:54:34 +01:00
jos 86e15f74e2 Added some unit tests 2015-02-28 15:04:46 +01:00