Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

[bug] Error: SimpleJekyllSearch --- You must specify a json #36

Closed
nakoo opened this issue Jun 6, 2015 · 16 comments
Closed

[bug] Error: SimpleJekyllSearch --- You must specify a json #36

nakoo opened this issue Jun 6, 2015 · 16 comments

Comments

@nakoo
Copy link

nakoo commented Jun 6, 2015

bug

I changed recent version updated on github and I get this error message.
My json setting is just default. Please check it.

@lengerfulluse
Copy link

I got the similar error about can't found the search.json. My search json just put in the path root. Could you please help to check it?
simple_jekyll_search-error

@nakoo nakoo changed the title [bug] Error: SimpleJekyllSearch --- You must specify a json label:bug Error: SimpleJekyllSearch --- You must specify a json Jun 7, 2015
@nakoo nakoo changed the title label:bug Error: SimpleJekyllSearch --- You must specify a json [bug] Error: SimpleJekyllSearch --- You must specify a json Jun 7, 2015
@christian-fei
Copy link
Owner

Thanks for reporting, and sorry for the inconvenience :(

Could you please post the code how you initialize the library?

@daviddarnes
Copy link
Contributor

If this is related to the initialising the plugin then I might have had the same issue basekit/docs.basekit.com#89

@nakoo
Copy link
Author

nakoo commented Jun 7, 2015

@christian-fei: Here you go. =)

SimpleJekyllSearch({
searchInput: document.getElementById('input'),
resultsContainer: document.getElementById('results'),
dataSource: '/search.json'
})

@christian-fei
Copy link
Owner

Ah i see, it seems you're missing the 'json' field (instead of dataSource).
I did a terrible job at versioning this time, will do better in the future.

https://github.com/christian-fei/Simple-Jekyll-Search#json-stringjson-required

Please let me know if it works, and sorry for the waste of time

@nakoo
Copy link
Author

nakoo commented Jun 7, 2015

@christian-fei: Oh, I didn't notice that. It works! Thanks =)

@nakoo nakoo closed this as completed Jun 7, 2015
@daviddarnes
Copy link
Contributor

@christian-fei that'll explain why my version breaks when I update. Could this be documented somewhere for people who upgrade their version of the package?

@lengerfulluse
Copy link

@christian-fei would you please help to take a look my code? It just keep with the error of 'failed to get JSON'(as the the screenshot state above).
Here is my javascript code:

<script src="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/dest/jekyll-search.js" type="text/javascript"></script>
<script type="text/javascript">
  SimpleJekyllSearch({
    searchInput: document.getElementById('search'),
    resultsContainer: document.getElementById('results-container'),
    json: '/search.json',
    searchResultTemplate: '<li><a href="{url}" title="{desc}">{title}</a></li>',
    noResultsText: 'No results found',
    limit: 10,
    fuzzy: false,
    exclude: ['Welcome']
  })
</script>

and my css code is as following:

       <div class="nav-search">
            <span class="search-input"><input type="text" id="search" placeholder="Article..." /></span>
            <span class="icon"><i class="fa fa-search"></i></span>
            <ul id="results-container"></ul>
        </div>

Thanks in advance!

@nakoo
Copy link
Author

nakoo commented Jun 8, 2015

@lengerfulluse: Did you add simple_search_filter.rb file to _plugins folder?
https://github.com/christian-fei/Simple-Jekyll-Search#if-search-isnt-working-due-to-invalid-json
also check in json file whether to have set up 'remove_chars'.
I think the problem is occurred for the setting of full-text search.

@christian-fei
Copy link
Owner

@lengerfulluse I think it's because of an invalid JSON,

callback(err, null)

Try to validate it here: http:https://jsonlint.com/

@lengerfulluse
Copy link

Wow, It did was caused by the setting of full-text search, which caused a invalid JSON.
Cool! Thanks @nakoo and @christian-fei !

@lengerfulluse
Copy link

Sorry guys, I just found that it only work in localhost( i run jekyll s , and search plugin can work well on localhost:4000). Unfortunately thing is that once i put the code into online(http:https://t.hengwei.me), it still got the same error of failed to get /search.json. Do you have ever met the similar problems? Thanks in advance!

@stramargio
Copy link

First of all, thanks in advance for your code!

Here the problem still remains...
JSON is well formatted, the path is in the right place, but it still got the same error:

Uncaught Error: SimpleJekyllSearch --- failed to get JSON (/search.json)

Here the way I initialize the plugin:

SimpleJekyllSearch({
  searchInput: document.getElementById('search-input'),
  resultsContainer: document.getElementById('results-container'),
  json: '/search.json'
});

And this is the well-formatted json... Any idea?

@una
Copy link

una commented Mar 9, 2016

I was getting the same problem, @kentoo -- adding the plugin to strip characters solved it for me (it turns out I had some @ in a tag (for @import) and it was creating invalid json

@stramargio
Copy link

It's true! Thanks a lot.

@christian-fei
Copy link
Owner

Thanks @una !

pvzhelnov added a commit to drzhelnov/zheln.github.io that referenced this issue Sep 23, 2020
Like OP recommended:

christian-fei/Simple-Jekyll-Search#36

Checked the json on:

https://jsonlint.com

Let’s see what it does.
pvzhelnov added a commit to drzhelnov/zheln.github.io that referenced this issue Sep 23, 2020
🎉

Finally, the malformed JSON was a problem
like OP wrote:

christian-fei/Simple-Jekyll-Search#36 (comment)

Thanks, man! 😎 @christian-fei
Both for the plugin _and_ the support! 👌
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants