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

bookmark list output is not a valid JSON #150

Open
jegwastaken opened this issue May 11, 2024 · 3 comments
Open

bookmark list output is not a valid JSON #150

jegwastaken opened this issue May 11, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@jegwastaken
Copy link

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

@MohamedBassem
Copy link
Collaborator

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!

@MohamedBassem MohamedBassem added the bug Something isn't working label May 11, 2024
@MohamedBassem MohamedBassem changed the title Is there a better way to mass export bookmarks? bookmark list output is not a valid JSON May 11, 2024
@jegwastaken
Copy link
Author

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
    }
  },
  ...
]

kamtschatka pushed a commit to kamtschatka/hoarder-app that referenced this issue May 19, 2024
fixed the encoding issue by using json.stringify to get parsable JSON
@kamtschatka
Copy link
Contributor

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"?

kamtschatka pushed a commit to kamtschatka/hoarder-app that referenced this issue May 24, 2024
Reworked the cli to switch over to json output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants