+2
Besvaret

Can you provide a quick little JSON building 101?

thillsman 11 år siden opdateret af ajones 11 år siden 5
I'm playing around with the datasource add property to build a local datasource from a remote one. (Thanks, Adam!) But I'm having some trouble. Can you give me the most stripped down example of a WIRE that adds to a local JSON file?

(I'm mostly interested in the datasource line referencing the local file at the top of the WIRE, as well as where exactly the ".add" property sticks the code within the local file.)

Thanks!
Absolutely. I'll get that example up by tomorrow morning. (Have to jump between doctor visits today)
Thanks, Adam! The code you sent me is really helpful. I tried to strip it down to the bare essentials, but I think I'm missing something. Just crashing all over.
Tyler, took the liberty of taking a little more time and authoring a blog post on the topic. Key terms you'll want to be familiar with before taking this on:

[eval] statements
blocks
dataSourceResultCount
querycomplete

Enjoy and happy coding.
http://www.moderndukes.com/post/42320...
Thanks again, Adam. Brilliant.

A couple questions:
- My new resident datasource is stored on the device, so it acts like [preferences:] rather than a [var:], right? Meaning the data is still stored when the app is closed and should not need to be downloaded again when the app is reopened? (Assuming no change in the original datasource.)
- Similarly: to clear out my resident datasource, I should use .removeIndex, right? Basically the same process as building the datasource, just in reverse?

This is good stuff.
The new datasource is not stored longterm. So it's more of a [var:] than a [preferences:].

The other thing to remember, any time that the master feed is requeried and you have your action that is building your new custom datasource will trigger the action again.

To clear out your datasource, you can do a quick little trick of just reseting your query on the new, custom datasource and it will blank out any attached list/tableviews/objects.


<assign property="datasource:customJSON.query" value="//xxyyzz" />


Another note, you can actually assign cache durations per datasource. So in your wire you can have two (or more) datasources with different caching values.

<datasource name="origin" source="" query="//sweet" providertype="json" urlcacheduration="259200" />

<datasource name="custom" source="" query="/sweeter" providertype="json" urlcacheduration="86400" >

Kundesupport af UserEcho