JSON parsing error for rendered output
See original GitHub issueI’m having trouble using citation.js to convert CSL JSON to rendered citations. Converting to bibtex works as expected.
Based on https://runkit.com/larsgw/591b5651bd9b40001113931c, I get the following results:
const Cite = require("citation-js")
const data = new Cite([{"id":78,"type":"article-journal","title":"Identification of Positive Regulators of the Yeast Fps1 Glycerol Channel","container-title":"PLoS Genet","page":"e1000738","volume":"5","issue":"11","source":"PLoS Genet","journalAbbreviation":"PLoS Genet","author":[{"family":"Beese","given":"Sara E."},{"family":"Negishi","given":"Takahiro"},{"family":"Levin","given":"David E."}]}])
data.get({
type: 'html',
style: 'bibtex'
})
gives
@article{BeeseIdentification,
author={Sara E. Beese and Takahiro Negishi and David E. Levin},
journal={PLoS Genet},
issue=11,
pages={e1000738},
title={{Identification of Positive Regulators of the Yeast Fps1 Glycerol Channel}},
volume=5,
}
In contrast,
const Cite = require("citation-js")
const data = new Cite([{"id":78,"type":"article-journal","title":"Identification of Positive Regulators of the Yeast Fps1 Glycerol Channel","container-title":"PLoS Genet","page":"e1000738","volume":"5","issue":"11","source":"PLoS Genet","journalAbbreviation":"PLoS Genet","author":[{"family":"Beese","given":"Sara E."},{"family":"Negishi","given":"Takahiro"},{"family":"Levin","given":"David E."}]}])
data.get({
type: 'html',
style: 'citation-apa'
})
gives the error
SyntaxError: Unexpected token u in JSON at position 0
(see https://runkit.com/5af4a2c58a83410012ddbf47/5af4a2d65bba2900126994f2#)
If I use new Cite('Q21972834')
instead of using raw CSL-JSON as input both work. Any idea what’s going on here?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
JSON.parse() parses a string as JSON. This string has to be valid JSON and will throw this error if incorrect syntax was encountered....
Read more >Error when trying to use output of Parse JSON
I used the payload to create the schema and the parse runs fine, rendering all the data into the proper variable names. I...
Read more >Getting error parsing and displaying JSON object in ReactJS
Here is the code as it is: import React, { Component } from 'react'; class WhoIs extends Component { render() { var origObject...
Read more >How to handle invalid JSON parse error properly.
The most common way to handle JSON parse error is using try-catch block. If the JSON string is valid, it will return a...
Read more >BEE Plugin Tech Docs | JSON Parser errors
1 : In case of a Bump error, the JSON parser forwards to the user the error ... 4602, Rendering error, 403 Forbidden,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here’s a demo on how to use the RIS output BTW: https://runkit.com/larsgw/citation.js-ris-output-demo
Basically this:
Or, with the new API:
Additionally, you can pass parameters:
I released the
v0.4.0-3
beta with RIS support, the CDN should load up soon: