Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json conversion problem if raw format is marcxml #8

Open
uleodolter opened this issue Oct 23, 2017 · 3 comments
Open

json conversion problem if raw format is marcxml #8

uleodolter opened this issue Oct 23, 2017 · 3 comments
Assignees

Comments

@uleodolter
Copy link

It seems that the conversion to json or xml works if raw format is usmarc, but it does not work if raw format is marcxml. I am unsure if it is related to missing record xmlns for this datasource.

'use strict';

const zoom = require('node-zoom2');

var sru = zoom.connection('obv-at-obvsg.userservices.exlibrisgroup.com')
  .set('sru','get')
  .set('sru_version','1.2')
  .set('schema','marcxml')
  .set('databaseName', 'view/sru/43ACC_NETWORK')
  .query('cql', 'alma.other_system_number = (AC02222419)')
  .createReadStream()
  .on('data', (record) => {
    console.log(record.xml);
    console.log(record.json);  // parsing error
  });
@dengelke
Copy link
Owner

Thanks for the connection details, the <record xmlns=""> is a tad concerning. I'll try debugging this directly with Yaz later just to make sure this isn't a bug with node-zoom2.

@uleodolter
Copy link
Author

uleodolter commented Jul 4, 2018

Hi,

Now we have xmlns but i get JSON parsing error wenn running the script above. Maybe i my code is wrong and zoom does not automatically convert marcxml to json ?

<record xmlns="http://www.loc.gov/MARC21/slim">
^

SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at Record.get json [as json] (/home/ulrich/Projects/alma/sru-test/node_modules/node-zoom2/lib/record.js:15:17)
    at ReadStream.zoom.connection.set.set.set.set.query.createReadStream.on (/home/ulrich/Projects/alma/sru-test/test.js:14:24)
    at emitOne (events.js:116:13)
    at ReadStream.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at ReadStream.Readable.push (_stream_readable.js:208:10)
    at ReadStream.stream._read (/home/ulrich/Projects/alma/sru-test/node_modules/node-zoom2/lib/read-stream.js:55:8)
    at ReadStream.stream._zoomReady (/home/ulrich/Projects/alma/sru-test/node_modules/node-zoom2/lib/read-stream.js:113:10)

@dengelke
Copy link
Owner

Hi @uleodolter I'm able to replicate the same issue on zoomsh by the following:
zoomsh
set sru get
set sru_version 1.2
set schema marcxml
databaseName view/sru/43ACC_NETWORK
search cql: alma.other_system_number = (AC02222419)
show 0 1 json
Has the exact same error, must be an issue with the record and zoom (the indenting does look unusual)

@dengelke dengelke self-assigned this Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants