Comments (6)
In terms of creating instances of objects in your application, or fetching JSON from an endpoint and using that to generate objects using Remodel?
from remodel.
from remodel.
@avnerbarr there's no built-in support for parsing JSON objects in Remodel objects, but it would be relatively straight-forward to write a plugin that would do that for you, depending on if you need to add support for nested object types. Could you provide a sample response?
from remodel.
I have a very complex JSON with lots of nesting but in general it could be something like
[
{
"_id": "586bc0e867eb88690303b838",
"index": 0,
"guid": "1a69dde7-59f3-4daf-8f94-76e168f71a4d",
"isActive": false,
"balance": "$1,496.45",
"picture": "http://placehold.it/32x32",
"age": 25,
"eyeColor": "green",
"name": "Julia Ford",
"gender": "female",
"company": "COMVEYOR",
"email": "[email protected]",
"phone": "+1 (857) 580-2018",
"address": "416 Oriental Boulevard, Skyland, Tennessee, 3208",
"about": "Lorem aute fugiat sunt sint magna qui et laboris. Aute ut ad ipsum cupidatat culpa ea sit cillum. Laborum irure id proident pariatur non nulla Lorem anim enim id voluptate deserunt aute dolor. Lorem ullamco deserunt laboris aliqua pariatur ex id. Mollit labore ea nostrud exercitation est culpa anim ea enim. Nisi reprehenderit ad ullamco do aliqua ea culpa cillum consectetur eu id amet ad.\r\n",
"registered": "2015-02-13T10:05:01 -02:00",
"latitude": -65.19895,
"longitude": -95.259513,
"tags": [
"duis",
"reprehenderit",
"deserunt",
"fugiat",
"quis",
"aliquip",
"elit"
],
"friends": [
{
"id": 0,
"name": "Lorena Day"
},
{
"id": 1,
"name": "Vanessa Pratt"
},
{
"id": 2,
"name": "Bridget Willis"
}
],
"greeting": "Hello, Julia Ford! You have 3 unread messages.",
"favoriteFruit": "banana"
}
]
from remodel.
@avnerbarr, this is an ideal use case for a plugin.
If you check out the section in this document called "Customizing Remodel", you can find a rough example of building a plugin.
Also, this document has more thorough information about the mechanics of setting one up.
from remodel.
Here's a basic JSON plugin, that let's you both
- create an object from a JSON dictionary and
- create a JSON dictionary from an object
https://gist.github.com/calimarkus/c4287bea1a7ae5a9e2ebcd53d93e5c12
This is not tested in any way and thus not production ready.
Take it as a starting point to write your own plugin.
It also doesn't support nested objects in its current state.
from remodel.
Related Issues (19)
- Swift example? HOT 1
- Doesn't import classes which are included via generics, even given an explicit `%import` HOT 1
- .valueObjectConfig is not documented in README HOT 1
- Self-referential algebraic data type does not forward-declare if the reference is within generics HOT 1
- Having issues with requiring dependencies for custom plugin HOT 1
- Allow algebraic matching blocks to be nil HOT 2
- run 'remodel-gen' command error HOT 1
- Travis CI
- ReferenceError: parsedType is not defined HOT 1
- Properties of type (or backing type) dispatch_block_t should be copied
- Support of Alternative Encoding Format HOT 1
- Parser rejects comments after %type directives HOT 3
- Comparison with Pinterest Plank HOT 2
- Using a repeated function prefix with different parameter names HOT 2
- Cast to %ld and %lu instead of issuing %zd and %tu specifiers for NSInteger and NSUInteger variables HOT 2
- Issue Getting IGListDiffable Plugin Installed HOT 1
- Alternative Kotlin or Java output? HOT 1
- How to use SIMD types HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remodel.