Invalid manifest (Solved)

Hello, im trying to make my own mod, but for some reason i can’t test the mod, cause it says invalid manifest.
And i kinda want to know, what can cause it so i can fix it.
also can invalid manifest also mean that there is something else wrong then the manifest.json file?

Alright, third attempt:

It could be the comments, I think Stonehearth’s JSON parser (which I still very much dislike) doesn’t appreciate those.

If I had the manifest.json (and the error message), I could tell you more.

the problem is i can’t check the exact problem since i can’t click on the mod and activate it in stonehearth.
but i can upload my mod file

@RepeatPan is most likely correct - remove the comments and try again.
In JSON, “//{text}” does not actually count as a comment as far as I know - and I don’t think there is any accepted comment-structure at all to be honest.

In JSON files, everything is considered data.
You could use something like to validate your JSON files :slight_smile:

1 Like

It really depends on the JSON implementation. For example, JSON.NET is happily accepting comments, does not complain about excess commas ({ "foo": "bar", }) and has other, not-quite-specification-valid features.

Stonehearth’s parser seems rather incomprehensible at times. As example,

  // Hello.
  "info": { 
    // again,
    "name": "Foobar"
  } // and again.

is accepted, whereas

  "info": { 
    "name": "mod" // Hello

is not (error parsing json: Removing white space failed). So judging from that, the general rule seems to be “Comments are fine, as long as they are either on the line of a closing object/array, or standalone”… or something like that.

Like I’ve said, I’m spoiled by JSON.NET’s usual “Just give me whatever” attitude, up to the point where it’s a bit frustrating to work with more strict implementations. As a general rule of thumb, I’d avoid comments completely in SH, as they seem to be a bit unforeseeable.

1 Like

I’m fairly new to working with JSON files, so this might be a silly question, but when you say

are you refering to what language will utilize the JSON file? (with language in this case, I’m talking about the language the calling functions are written in)

I am under the impression that JSON files are data-files, which should be able to be read by any language; comment-structure of C++ and Python does not match - so, to me, it seems that “//Hello” would work for C++ but not Python interpreters/compilers.

i just tryed validate json, and it said it was valid
i have also removed the comments,
i think it works, but so far i can’t start op stonehearth or rather it’s a blackscreen
so i will now check through my code with the json validater

JSON (ignoring its origin, which is technically JavaScript…ish) is data, as you’ve already correctly stated. But data is data, it’s a bunch of bytes, it’s up to whatever is reading/parsing/interpreting it what to do with it. It has nothing to do with the language, but the rather the libraries (or more specifically, the algorithms) that are utilised. I would argue that for most common languages, you’ll find at least two different JSON libraries that both handle certain edge cases (like comments) differently.

Of course there’s the one big specification that everyone should adhere to, but libraries are free to extend on that standard. In this case, technically comments are both legal and illegal (as far as I know they’ve been in an earlier version of the standard, then got kicked out, but the specification says that parsers are “free to support extensions”). By allowing comments in the files you’re reading, you’re extending on JSON; you’re able to read normal JSON and JSON with comments.

But again, this has absolutely nothing to do with the language. You can probably find Python parsers that allow // Foo comments too, and I’m sure somebody wrote a JSON parser that uses # Foo as comment syntax. Because it’s data, it’s decoupled from the program executing it.

That can be an indicator of a bad manifest, though. Check your stonehearth.log, or upload it somewhere, along with the mod.

1 Like

Thank you for the more in-depth explanation; things like this really helps me (and others?) to understand what’s going on “automagically”. :+1:

I think I will hold on to my “no comments in JSON files”-thoughts when it comes to Stonehearth mods for now.
But, thanks to you, I shall not lock my thoughts to believe that this would be the case with JSON files in general.

I can confirm that JS-style comments do not work with Stonehearth’s JSON parser properly. In fact, in some places you’ll see throwaway properties like "__comment" that they used for this purpose. It is a little annoying, but that’s what it is.

Yea i figured it out :slight_smile: it was the comments :confused:
And it works now also the json validator is really helpful :smiley:

1 Like

Which is kinda funny. I don’t know if SH actually filters out those entries, or whether they actually end up in lua tables too. In any case, certain JSON parsers do not accept multiple keys for the same object (or have different behaviours, which isn’t really relevant in this case as we’re not going to read the entries), so that approach could give headaches to 3rd party tools as well. Not to mention that formatting these files with auto-formatters (or if your IDE is doing it) could mess up the comments (as example, constants.json, where the comments are after the property).

JSON is beautiful, isn’t it.