Skip to content

Commit 44cc16c

Browse files
committed
jQuery.parseJSON: Move the deprecation note to the top, rephrase it
The deprecation note has been moved to the top of the description as it's the most important information about the API. This is also how other pages for deprecated APIs are documented. Also, the message has been rephrased a little as JSON is a string, not an object. Ref jquery#899 Closes jquery#1000
1 parent 244b0b0 commit 44cc16c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

entries/jQuery.parseJSON.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
</signature>
1515
<desc>Takes a well-formed JSON string and returns the resulting JavaScript value.</desc>
1616
<longdesc>
17+
<p>As of jQuery 3.0, <code>$.parseJSON</code> is deprecated. To parse JSON strings use the native <code>JSON.parse</code> method instead.</p>
1718
<p>Passing in a malformed JSON string results in a JavaScript exception being thrown. For example, the following are all invalid JSON strings:</p>
1819
<ul>
1920
<li><code>"{test: 1}"</code> (test does not have double quotes around it).</li>
@@ -26,7 +27,6 @@
2627
<p>The JSON standard does not permit "control characters" such as a tab or newline. An example like <code>$.parseJSON( '{ "testing":"1\t2\n3" }' )</code> will throw an error in most implementations because the JavaScript parser converts the string's tab and newline escapes into literal tab and newline; doubling the backslashes like <code>"1\\t2\\n3"</code> yields expected results. This problem is often seen when injecting JSON into a JavaScript file from a server-side language such as PHP.</p>
2728
<p>Where the browser provides a native implementation of <code>JSON.parse</code>, jQuery uses it to parse the string. For details on the JSON format, see <a href="http://json.org/">http://json.org/</a>.</p>
2829
<p>Prior to jQuery 1.9, <code>$.parseJSON</code> returned <code>null</code> instead of throwing an error if it was passed an empty string, <code>null</code>, or <code>undefined</code>, even though those are not valid JSON.</p>
29-
<p>As of jQuery 3.0, <code>$.parseJSON</code> is deprecated. To parse JSON objects, use the native <code>JSON.parse</code> method instead.</p>
3030
</longdesc>
3131
<example>
3232
<desc>Parse a JSON string.</desc>

0 commit comments

Comments
 (0)