195 lines
5.4 KiB
HTML
195 lines
5.4 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset='UTF-8'>
|
|
<title>Yatta! Documentation</title>
|
|
<script src='../javascript/application.js'></script>
|
|
<script src='../javascript/search.js'></script>
|
|
<link rel='stylesheet' href='../stylesheets/application.css' type='text/css'>
|
|
</head>
|
|
<body>
|
|
<div id='base' data-path='../'></div>
|
|
<div id='header'>
|
|
<div id='menu'>
|
|
<a href='../extra/README.md.html' title='Yatta!'>
|
|
Yatta!
|
|
</a>
|
|
»
|
|
<a href='../alphabetical_index.html' title='Index'>
|
|
Index
|
|
</a>
|
|
»
|
|
<span class='title'>JsonWrapper</span>
|
|
</div>
|
|
</div>
|
|
<div id='content'>
|
|
<h1>
|
|
Class:
|
|
JsonWrapper
|
|
</h1>
|
|
<table class='box'>
|
|
<tr>
|
|
<td>Defined in:</td>
|
|
<td>lib/Types/JsonTypes.coffee</td>
|
|
</tr>
|
|
</table>
|
|
<h2>Overview</h2>
|
|
<div class='docstring'>
|
|
<div class='note'>
|
|
<strong>Note:</strong>
|
|
You can only overwrite existing values! Setting a new property won't have any effect!
|
|
</div>
|
|
<p>A JsonWrapper was intended to be a convenient wrapper for the JsonType.
|
|
But it can make things more difficult than they are.</p><p>It creates Javascripts -getter and -setter methods for each property that JsonType maintains.</p><p>In order to set a new property you have to overwrite an existing property.
|
|
Therefore the JsonWrapper supports a special feature that should make things more convenient
|
|
(we can argue about that, use the JsonType if you don't like it ;).
|
|
If you overwrite an object property of the JsonWrapper with a new object, it will result in a merged version of the objects.
|
|
Let w.p the property that is to be overwritten and o the new value. E.g. w.p = o</p><ul>
|
|
<li>The result has all properties of o</li>
|
|
<li>The result has all properties of w.p if they don't occur under the same property-name in o.</li>
|
|
</ul>
|
|
|
|
<div class='examples'>
|
|
<h3>Examples:</h3>
|
|
<h4>
|
|
create a JsonWrapper
|
|
</h4>
|
|
<pre><code class='coffeescript'># You get a JsonWrapper from a JsonType by calling
|
|
w = yatta.value</code></pre>
|
|
<h4>
|
|
Getter Example
|
|
</h4>
|
|
<pre><code class='coffeescript'># you can access the x property of yatta by calling
|
|
w.x
|
|
# instead of
|
|
yatta.val('x')</code></pre>
|
|
<h4>
|
|
Setter Example
|
|
</h4>
|
|
<pre><code class='coffeescript'># you can set an existing x property of yatta by calling
|
|
w.x = "text"
|
|
# instead of
|
|
yatta.val('x', "text")</code></pre>
|
|
<h4>
|
|
Conflict Example
|
|
</h4>
|
|
<pre><code class='coffeescript'>yatta.value = {a : "string"}
|
|
w = yatta.value
|
|
console.log(w) # {a : "string"}
|
|
w.a = {a : {b : "string"}}
|
|
console.log(w) # {a : {b : "String"}}
|
|
w.a = {a : {c : 4}}
|
|
console.log(w) # {a : {b : "String", c : 4}}</code></pre>
|
|
<h4>
|
|
Common Pitfalls
|
|
</h4>
|
|
<pre><code class='coffeescript'>w = yatta.value
|
|
# Setting a new property
|
|
w.newProperty = "Awesome"
|
|
console.log(w.newProperty == "Awesome") # false, w.newProperty is undefined
|
|
# overwrite the w object
|
|
w = {newProperty : "Awesome"}
|
|
console.log(w.newProperty == "Awesome") # true!, but ..
|
|
console.log(yatta.value.newProperty == "Awesome") # false, you are only allowed to set properties!
|
|
# The solution
|
|
yatta.value = {newProperty : "Awesome"}
|
|
console.log(w.newProperty == "Awesome") # true!</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class='tags'>
|
|
<h3>See also:</h3>
|
|
<ul class='see'>
|
|
<li>
|
|
<a href='../class/JsonType.html'>JsonType</a>
|
|
</li>
|
|
<li>
|
|
<a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty'>https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<h2>Constructor Details</h2>
|
|
<div class='methods'>
|
|
<div class='method_details'>
|
|
<p class='signature' id='constructor-dynamic'>
|
|
#
|
|
(void)
|
|
<b>constructor</b><span>(jsonType)</span>
|
|
<br>
|
|
</p>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id='footer'>
|
|
August 05, 14 16:58:39 by
|
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
|
Codo
|
|
</a>
|
|
2.0.9
|
|
✲
|
|
Press H to see the keyboard shortcuts
|
|
✲
|
|
<a href='http://twitter.com/netzpirat' target='_parent'>@netzpirat</a>
|
|
✲
|
|
<a href='http://twitter.com/_inossidabile' target='_parent'>@_inossidabile</a>
|
|
</div>
|
|
<iframe id='search_frame'></iframe>
|
|
<div id='fuzzySearch'>
|
|
<input type='text'>
|
|
<ol></ol>
|
|
</div>
|
|
<div id='help'>
|
|
<p>
|
|
Quickly fuzzy find classes, mixins, methods, file:
|
|
</p>
|
|
<ul>
|
|
<li>
|
|
<span>T</span>
|
|
Open fuzzy finder dialog
|
|
</li>
|
|
</ul>
|
|
<p>
|
|
Control the navigation frame:
|
|
</p>
|
|
<ul>
|
|
<li>
|
|
<span>L</span>
|
|
Toggle list view
|
|
</li>
|
|
<li>
|
|
<span>C</span>
|
|
Show class list
|
|
</li>
|
|
<li>
|
|
<span>I</span>
|
|
Show mixin list
|
|
</li>
|
|
<li>
|
|
<span>F</span>
|
|
Show file list
|
|
</li>
|
|
<li>
|
|
<span>M</span>
|
|
Show method list
|
|
</li>
|
|
<li>
|
|
<span>E</span>
|
|
Show extras list
|
|
</li>
|
|
</ul>
|
|
<p>
|
|
You can focus and blur the search input:
|
|
</p>
|
|
<ul>
|
|
<li>
|
|
<span>S</span>
|
|
Focus search input
|
|
</li>
|
|
<li>
|
|
<span>Esc</span>
|
|
Blur search input
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html> |