Hi David,

On Wed, 26 Sep 2018 15:13:14 +1000 David Ireland <[email protected]> wrote:

> I've started using Awful 1.0 and having trouble returning a JSON string. The 
> inverted commas are being replaced by &quot. For example, using
> the code below returns {&quot;a&quot; : 1 }
>
> Should this be normal behavior when returning JSON strings? 

Awful uses sxml-transforms behind the scenes to convert SXML to HTML,
and the sxml->html converter transforms `'' into `&quot;'.  You can
prevent that by using `(literal ,my-json) in your code.  Example:

(define-json (main-page-path)
  (λ ()
    `(literal ,my-json)))

I see this is wrong in the documentation.  I'm gonna fix it.  Thanks for
reporting.

All the best.
Mario

> (use awful) 
> (enable-sxml #t) 
>
> (define my-json "{\"a\" : 1 }") 
>
> (define (define-json path body) 
> (define-page path 
> (λ () 
> (awful-response-headers '((content-type "text/json"))) 
> (body)) 
> no-template: #t)) 
>
> (define-json (main-page-path) 
> (λ () `(,my-json))) 
>
>
> _______________________________________________
> Chicken-users mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/chicken-users
>

-- 
http://parenteses.org/mario

_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to