Comments (4)
Hi,
I'm interested in getting JSON output for your classes to store the results in MongoDB. I went ahead and experimented with the code base, knowing not much of PHP:
use JsonSerializable;
class Vehicle implements JsonSerializable {
* Get the json representation of the object
*
* @return string
*/
public function jsonSerialize() {
return [
'name' => $this->getName(),
'type' => $this->getType(),
'class' => $this->getClass(),
'number' => $this->getNumber(),
'ballast' => $this->getBallast(),
'restrictor' => $this->getRestrictor(),
'skin' => $this->getSkin(),
'friendlyName' => $this->getFriendlyName()
];
}
As you're far more knowledgable on PHP than I ever will be, do you think this is a sound approach? If so, I'll continue and push it to github.
from simresults.
Yes I think this would be the approach :) Anyway create it what works for you. Eventually when I have time one day, I might use it. Thanks for wanting to share with others!
from simresults.
Hi, thanks for the encouraging words. I cloned your repo and added JSON serialize functions to most classes: https://github.com/tspindler-cms/simresults I'm not sure on how to proceed on testing these, would you happen to have some ideas for that?
from simresults.
Cool! 👍 Take a look at the specs folder. You could add a function called called it_can_cast_to_json
to a specific class test file. Set some test values and then check the json output.
For example see it_can_cast_to_string
on LapSpec
. Very similar:
https://github.com/mauserrifle/simresults/blob/develop/spec/Simresults/LapSpec.php#L23
You can run the spec tests using ./vendor/bin/phpspec run
from simresults.
Related Issues (20)
- installation HOT 3
- Automobilista 2 HOT 5
- About vehicle name of ACC result page HOT 1
- ACC: Fix duplicate decoding code
- API Behaviour HOT 10
- user_id HOT 6
- ACC: import driver class (cupCategory) from results HOT 3
- No Sector Times for RaceRoom HOT 3
- RaceRoom including DNF lap in counter HOT 3
- Automobilista 2 results - sporadic return of steamid HOT 7
- ACC Lap 1 S1 issue when time is inaccurate HOT 12
- PC2 Final Race Position Issue HOT 1
- API config question HOT 5
- Allow ACC result json files to be read by the remote api HOT 2
- Disable cache in reader code
- Teams Column in AC HOT 2
- Add cup name to Vehicle::getFriendlyName
- Consistency per driver on races with swaps
- Report which reader generated the session object
- Move bug fixes in integration tests to bottom
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 simresults.