[GH-ISSUE #150] bookmark list output is not a valid JSON #119

Closed
opened 2026-03-02 11:46:48 +03:00 by kerem · 3 comments
Owner

Originally created by @jegwastaken on GitHub (May 11, 2024).
Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/150

With the CLI, hoarder bookmarks list > bookmarks.json kinda works, but it outputs malformed/invalid JSON.

Originally created by @jegwastaken on GitHub (May 11, 2024). Original GitHub issue: https://github.com/karakeep-app/karakeep/issues/150 With the CLI, `hoarder bookmarks list > bookmarks.json` kinda works, but it outputs malformed/invalid JSON.
kerem 2026-03-02 11:46:48 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@MohamedBassem commented on GitHub (May 11, 2024):

hmmm, the output of bookmark list is supposed to be a well-formed JSON. Just checked and I think I saw the bug. Dates are not quoted. I'll fix it :) Thanks for the report!

<!-- gh-comment-id:2106052337 --> @MohamedBassem commented on GitHub (May 11, 2024): hmmm, the output of `bookmark list` is supposed to be a well-formed JSON. Just checked and I think I saw the bug. Dates are not quoted. I'll fix it :) Thanks for the report!
Author
Owner

@jegwastaken commented on GitHub (May 11, 2024):

I think both keys and string values should be in double quotes. Other JSON issues I noticed:

  • Some descriptions contain multiple quoted parts (and sometimes a plus sign) for some reason.
  • htmlContent: '<div id="r... <CROPPED>' seems problematic. Maybe a simpler "htmlContent": "<CROPPED>" would be better?

Example output:

[
  {
    id: 'xxxxxxxxx',
    createdAt: 2024-05-11T16:51:13.000Z,
    title: null,
    archived: false,
    favourited: false,
    taggingStatus: 'success',
    note: null,
    tags: [
      'Literature',
      'Fiction Writing',
      'Ernest Hemingway',
      'Writing Advice',
      'Author Techniques'
    ],
    content: {
      type: 'link',
      url: 'http://www.openculture.com/2013/02/seven_tips_from_ernest_hemingway_on_how_to_write_fiction.html',
      title: 'Seven Tips From Ernest Hemingway on How to Write Fiction',
      description: 'Image by Lloyd Arnold via Wikimedia Commons\n' +
        'Before he was a big game hunter, before he was a deep-sea fisherman, Ernest Hemingway was a craftsman who would rise very early in the morning and write.',
      imageUrl: 'https://cdn8.openculture.com/wp-content/uploads/2013/02/EH-354-e1361297347123.jpeg',
      imageAssetId: '43768e6a-bcc7-4655-9dfe-f69935d847ac',
      screenshotAssetId: '156d4d7a-c5a8-47a3-b067-2b32f7d03a92',
      favicon: 'https://cdn8.openculture.com/2017/06/17162746/OC-favicon-300x300.png',
      htmlContent: '<div id="r... <CROPPED>',
      crawledAt: 2024-05-11T18:08:22.000Z
    }
  },
  ...
]
<!-- gh-comment-id:2106054189 --> @jegwastaken commented on GitHub (May 11, 2024): I think both keys and string values should be in double quotes. Other JSON issues I noticed: - Some descriptions contain multiple quoted parts (and sometimes a plus sign) for some reason. - `htmlContent: '<div id="r... <CROPPED>'` seems problematic. Maybe a simpler `"htmlContent": "<CROPPED>"` would be better? Example output: ``` [ { id: 'xxxxxxxxx', createdAt: 2024-05-11T16:51:13.000Z, title: null, archived: false, favourited: false, taggingStatus: 'success', note: null, tags: [ 'Literature', 'Fiction Writing', 'Ernest Hemingway', 'Writing Advice', 'Author Techniques' ], content: { type: 'link', url: 'http://www.openculture.com/2013/02/seven_tips_from_ernest_hemingway_on_how_to_write_fiction.html', title: 'Seven Tips From Ernest Hemingway on How to Write Fiction', description: 'Image by Lloyd Arnold via Wikimedia Commons\n' + 'Before he was a big game hunter, before he was a deep-sea fisherman, Ernest Hemingway was a craftsman who would rise very early in the morning and write.', imageUrl: 'https://cdn8.openculture.com/wp-content/uploads/2013/02/EH-354-e1361297347123.jpeg', imageAssetId: '43768e6a-bcc7-4655-9dfe-f69935d847ac', screenshotAssetId: '156d4d7a-c5a8-47a3-b067-2b32f7d03a92', favicon: 'https://cdn8.openculture.com/2017/06/17162746/OC-favicon-300x300.png', htmlContent: '<div id="r... <CROPPED>', crawledAt: 2024-05-11T18:08:22.000Z } }, ... ] ```
Author
Owner

@kamtschatka commented on GitHub (May 19, 2024):

I had a look at the issue and the problem is, that console.dir does not perform a proper encoding, so I switched it to JSON.stringify with 4 space indentation to have the same formatting.

The overall issue is another one though:
The CLI is inconsistent. This is the only location where you actually get proper (after the fix) JSON. If you e.g. run lists list you will instead get a table that shows the lists:

+--------------------------+---------+
| Id                       | Name    |
| t2zqhh847wlaoe3ii4texu5t | 🚀 asdf |
| vujlkb7qf4thhblo4o24yg1b | 🚀 qwer |
+--------------------------+---------+

There is also a feature request (#43) to get a REST API. Maybe it makes sense to adapt the CLI with #43 to have a "--json" option as well, that will just return the JSON (for all commands) and respond with a more user friendly table if you don't specify "--json"?

<!-- gh-comment-id:2119146278 --> @kamtschatka commented on GitHub (May 19, 2024): I had a look at the issue and the problem is, that console.dir does not perform a proper encoding, so I switched it to JSON.stringify with 4 space indentation to have the same formatting. The overall issue is another one though: The CLI is inconsistent. This is the only location where you actually get proper (after the fix) JSON. If you e.g. run `lists list` you will instead get a table that shows the lists: ``` +--------------------------+---------+ | Id | Name | | t2zqhh847wlaoe3ii4texu5t | 🚀 asdf | | vujlkb7qf4thhblo4o24yg1b | 🚀 qwer | +--------------------------+---------+ ``` There is also a feature request (#43) to get a REST API. Maybe it makes sense to adapt the CLI with #43 to have a "--json" option as well, that will just return the JSON (for all commands) and respond with a more user friendly table if you don't specify "--json"?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/karakeep#119
No description provided.