Browse Source

custom json parsing

master
Victor Fors 2 years ago
parent
commit
d536380b51
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      parking.scm

+ 3
- 2
parking.scm View File

@@ -55,18 +55,19 @@

(define (get-parking-lots)
(let ((result (simple-json-request (string-append "http://parkering.linkoping.se/Parkeringsdata/ParkeringsdataV1.svc/GetParkeringsYtaList/" parking-key "/0"))))
(vector->list (value 'ParkingAreaNewList result))))
(value 'ParkingAreaNewList result)))

(define (computerized? lot)
(has-key? 'ParkingSpacesAvailable lot))

(define (only-has-handicap-spots? lot)
(equal? #(4) (value 'ParkingTypes lot)))
(equal? '(4) (value 'ParkingTypes lot)))

(define (electric-car-lot? lot)
(member? 3 (value 'ParkingTypes lot)))

(define (main)
(json-parsers (cons `(array . ,identity) (json-parsers)))
(display-newline "Parking spaces available:")
(let ((lots (sort-via string-ci<? (curry value 'Name) (get-parking-lots))))
(map (compose display-newline (curry format-assoc '(Name ": " ParkingSpacesAvailable "/" ParkingSpaces)))


Loading…
Cancel
Save