Skip to content

Example uses single quotes in erb and does not produce valid JSON #1

Open
@shadowbq

Description

@shadowbq

<% @objects.each do |object| %>
['<%= link_to(object.user.name, user) %>',
'<%= object.description || "-" %>',
'<%= object.created_at %>'
],

extracted.. "By far the most common error I’ve encountered relates to object keys. In JSON (unlike in JavaScript) these MUST be double-quoted strings. In fact, ALL strings in JSON must be enclosed in double quotes (JavaScript also allows single quotes; JSON does not)."

Valid:

{ "name": "Simon" }

Invalid:

{ name: "Simon" }
{ 'name': "Simon" }
{ "name": 'Simon' }
http://simonwillison.net/2006/oct/11/json/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions