Comments (5)
Can you give an example of what this would look like?
from klaxon.
Sure. So here is the example Apple Wallet pass:
{
"formatVersion" : 1,
"passTypeIdentifier" : "pass.com.apple.devpubs.example",
"serialNumber" : "E5982H-I2",
"teamIdentifier" : "A93A5CM278",
"webServiceURL" : "https://example.com/passes/",
"authenticationToken" : "vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc",
"barcode" : {
"message" : "123456789",
"format" : "PKBarcodeFormatPDF417",
"messageEncoding" : "iso-8859-1"
},
"locations" : [
{
"longitude" : -122.3748889,
"latitude" : 37.6189722
},
{
"longitude" : -122.03118,
"latitude" : 37.33182
}
],
"organizationName" : "Paw Planet",
"description" : "Paw Planet Coupon",
"logoText" : "Paw Planet",
"foregroundColor" : "rgb(255, 255, 255)",
"backgroundColor" : "rgb(206, 140, 53)",
"coupon" : {
"primaryFields" : [
{
"key" : "offer",
"label" : "Any premium dog food",
"value" : "20% off"
}
],
"auxiliaryFields" : [
{
"key" : "expires",
"label" : "EXPIRES",
"value" : "2013-04-24T10:00-05:00",
"isRelative" : true,
"dateStyle" : "PKDateStyleShort"
}
]
}
}
Suppose all I want to do is plugin my own organization id, I would want to do something like:
val pass = Parser().from(template).replace({ obj( "organizationId" to 12345678 ) })
and the result would be that that value was spliced in to the json which was copied from the parse operation.
from klaxon.
Sounds pretty useful but I'm not sure this belongs in a JSON parsing library. Better let the developer pick their own templating approach, for that (e.g. Mustache).
from klaxon.
The problem with treating it as a template is then it seems to undo one of the best parts of JSON: so we parse and stringify and then parse again to replace a single value?
I have heard your ruling though. :)
from klaxon.
Not that it means that much, doing this is pretty trivial in SwiftyJSON.
from klaxon.
Related Issues (20)
- Infinite floating point values cause invalid JSON to be written
- Could not compute caller for function: private constructor Int()
- Is there a memory-light way of doing URL -> Flow?
- ...
- Missing support for JSON Map HOT 3
- Unable to parse Boolean HOT 1
- Parsing number values HOT 1
- Parsing jsons with nullable fields - `serializeNull = false` as a default?
- [Bug] Unsigned numbers not correctly serialized
- Add support for JSON Lines HOT 1
- `JsonObject` created by `toJsonObject` from a derived class will not contain members of any superclass. HOT 1
- Docs are not clear on now to process a stream of json objects.
- Failure parsing json into class with primary constructor with parameters not specifying var or val
- Using a TypeAdapter with a default class for null?
- Unable to instantiate MyClass
- No accessors or field is found for property var XXXXXX: kotlin.String?
- KlaxonDoc.java got compiled to Java 11 byte code HOT 1
- Using Klaxon in Gradle Task
- Fails to handle case where enum is the key of a map inside a data class
- Optional property 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 klaxon.