Comments (5)
Hey @Whizboy-Arnold really sorry for the delay on this!
I will get a fix out for you soon which will allow you to customise the JSON flags.
from saloon.
@Sammyjo20 Hey.
I think what @Whizboy-Arnold means is that he'd like to add/overwrite the JSON flags in the JsonBodyRepository.
JSON should be escaped, like PHP does, but isn't required.
AFAIK, most people also don't escape it, unlike PHP.
I've also faced issues with escaped JSON in the past, where APIs don't actually support JSON, even though that's their 'data format'.
So I can relate to the situation.
That being said, you should be able to straight-off snag my 'HasJsonFlags' trait in my private concept repo (src/Concerns/HasJsonFlags), you've been invited to.
Then you should be able to add it to the JsonBodyRepository, and change
public function __toString(): string
{
return json_encode($this->all(), JSON_THROW_ON_ERROR);
}
to something like
public function __toString(): string
{
$json = is_null($this->getJsonFlags())
? json_encode($this->all())
: json_encode($this->all(), $this->getJsonFlags());
// If JSON_THROW_ON_ERROR is not set, turn `false` into an empty string.
return $json === false ? '' : $json;
}
Or if you want to enforce a JSON Exception, something like:
public function __toString(): string
{
return json_encode($this->all(), $this->getJsonFlags() | JSON_THROW_ON_ERROR);
}
Keep in mind, though, if this is done - using interface type hints will not resolve the new JSON flag methods.
from saloon.
Sorry I'm a little confused @Whizboy-Arnold - do you mind clarifying a little bit? Thanks!
from saloon.
Ok thank you for the support
from saloon.
Hey @Whizboy-Arnold I've made a PR (#229) to add support for this. Please could you take a look over it to see if it would be suitable for you?
from saloon.
Related Issues (20)
- Error when only connector has a body and request does not HOT 2
- Get clean API response when an exception occurs HOT 6
- Removal of key customisation in pagination? HOT 2
- Inquiring about the Option to Send the Path of a Certificate HOT 2
- BindingResolutionException on Connector if request is sent async HOT 17
- Asserting sent request fails on first test when recording responses HOT 6
- File Uploads Not Working HOT 18
- Log request and response HOT 5
- Caching with Offset Paginator returns same results for each API call. HOT 3
- InvalidArgumentException: A 'contents' key is required HOT 3
- Query parameters customisation HOT 10
- HasMultipartBody and multiple files with the same key HOT 3
- "Shifted" `$this->page` between `isLastPage()` and `applyPagination()` in pagination HOT 6
- API logs table HOT 6
- Rate Limit Handler Seems to Be Unreliable With Multiple Workers HOT 2
- AuthConnector::createOAuthAuthenticator(): Argument #2 ($refreshToken) must be of type string, null given HOT 5
- `HasReponse` trait causes exception HOT 5
- `HasReponse` only works on single item HOT 1
- Undefined class 'HeaderAuthenticator' HOT 4
- Typing of responses with DTO's HOT 3
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 saloon.