Comments (2)
For building arbitrary JSON data, a functional interface is probably best. e.g.
import jason.{object, string, boolean}
let body = jason.encode(
object(
[
tuple("id_token", string(id_token)),
tuple(
"userinfo",
object(
[
tuple("sub", string(email_address)),
tuple("email", string(email_address)),
tuple("email_verified", boolean(True)),
],
),
),
],
),
)
This is extensible with your own types, for example dates etc.
Also for simplicity I think the return value from object should be the same as the return value from a decode function.
Certainly the above is similar in complexity to building with types. but it is cheaper, less intermediate data structures and with the benefit of extensibility.
JsonObject(
[
tuple("id_token", JsonString(id_token)),
tuple(
"userinfo",
JsonObject(
[
tuple("sub", JsonString(email_address)),
tuple("email", JsonString(email_address)),
tuple("email_verified", JsonBool(True)),
],
),
),
],
),
And is conceptually simpler to building your own dynamic data structures.
let body = jason.encode(
dynamic.from(
map.from_list(
[
tuple("id_token", dynamic.from(id_token)),
tuple(
"userinfo",
dynamic.from(
map.from_list(
[
tuple("sub", dynamic.from(email_address)),
tuple("email", dynamic.from(email_address)),
tuple("email_verified", dynamic.from(True)),
],
),
),
),
],
),
),
)
from midas.
I will consider this done enough for milestone 0.2.0 the readme in gleam_jsone is enough information for now. However a general input parsing would be good, something that worked equally on querys form data and json.
from midas.
Related Issues (20)
- Docker HOT 1
- DB access HOT 8
- Create a template to start a new midas project HOT 2
- Input Parsing and error handling HOT 4
- Code reloading HOT 1
- Parameterize type of body in Request type HOT 1
- Put midas Dockerfile in this repo
- Routing/Endpoint DSL HOT 2
- Better typing for trapped exits and monitor messages HOT 5
- Supervisors are give a child spec with a run function rather than a spawn_link function HOT 1
- Cookie based Sessions + CSRF
- Flash messages in cookies
- HTML safe templates
- asset compilation
- Logging HOT 2
- Bug reporting
- Document a way to run "mix task"
- Using midas within a Phoenix project HOT 4
- Add Error handling to template example 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 midas.