php composer.json 错误:“./composer.json”不包含有效的 JSON

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18907987/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 18:26:48  来源:igfitidea点击:

composer.json error: "./composer.json" does not contain valid JSON

phpcomposer-phpdependency-management

提问by Adam

I made a composer.json script.

我做了一个 composer.json 脚本。

When I run sudo composer install, I get this error:

当我运行时sudo composer install,我收到此错误:

[Seld\JsonLint\ParsingException]               
"./composer.json" does not contain valid JSON  
Parse error on line 1:                         
"repositories": [    {        "t               
--------------^                                
Expected one of: 'EOF', '}', ',', ']'          

Here is the JSON:

这是JSON:

"repositories": [
    {
        "type":"package",
        "package": {
          "name": "AdamKyle/Aisis-Core",
          "version":"development",
          "source": {
              "url": "https://github.com/AdamKyle/Aisis-Core.git",
              "type": "git",
              "reference":"development"
            }
        }
    }
],
"require": {
    "AdamKyle/Aisis-Core": "development"
}

How can I get a better description of how this JSON is wrong?

我怎样才能更好地描述这个 JSON 是如何错误的?

回答by Eric Leschinski

Your JSON is bad, Paste your JSON into this website: http://jsonlint.com/

您的 JSON 不正确,请将您的 JSON 粘贴到此网站:http: //jsonlint.com/

It returns the error:

它返回错误:

Parse error on line 1:
"repositories": [  
^
Expecting '{', '['

If you surround your entire JSON with a {at the beginning and }at very end, the invalid JSON becomes valid.

如果您在整个 JSON{的开头和}结尾都用 a 括起来,则无效的 JSON 将变为有效。

回答by Jaydeep Marvaniya

You should add "["and "]"in the starting and ending of the file.

您应该在文件的开头和结尾添加"[""]"

回答by Nirav Joshi

Here you can use it like this.

在这里你可以像这样使用它。

Try with this it will helps you to recover your error.

试试这个它会帮助你恢复你的错误。

{
   "repositories": [{
     "type": "package",
     "package": {
        "name": "AdamKyle/Aisis-Core",
        "version": "development",
        "source": {
            "url": "https://github.com/AdamKyle/Aisis-Core.git",
            "type": "git",
            "reference": "development"
        }
    }
  }],
  "require": {
      "AdamKyle/Aisis-Core": "development"
  }
}

回答by Charlie

My text editor's quotation marks were invalid, try copying and pasting this one into your text file: "

我的文本编辑器的引号无效,请尝试将其复制并粘贴到您的文本文件中:"