I keep receiving this error message when I open Atom. i have tried looking into it but I can't seem to find where the error message is? Am I missing out something in the JSON file?
Error message title
Failed to load the my-package package
untitled1:1
LFUTF-8Plain Text
Failed to load the my-package package
Unexpected token } in JSON at position 160 in /Users/tech-a48/.atom/packages/my-package/package.json
Hide Stack Trace
SyntaxError: Unexpected token } in JSON at position 160
at Object.parse (native)
at parseObject (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/season/lib/cson.js:54:19)
at parseContentsSync (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/season/lib/cson.js:68:16)
at Object.readFileSync (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/season/lib/cson.js:170:14)
at PackageManager.module.exports.PackageManager.loadPackageMetadata (/Applications/Atom.app/Contents/Resources/app.asar/src/package-manager.js:721:29)
at PackageManager.module.exports.PackageManager.loadPackage (/Applications/Atom.app/Contents/Resources/app.asar/src/package-manager.js:434:35)
at /Applications/Atom.app/Contents/Resources/app.asar/src/package-manager.js:412:19
at Config.module.exports.Config.transact (/Applications/Atom.app/Contents/Resources/app.asar/src/config.js:312:16)
at PackageManager.module.exports.PackageManager.loadPackages (/Applications/Atom.app/Contents/Resources/app.asar/src/package-manager.js:407:19)
at /Applications/Atom.app/Contents/Resources/app.asar/src/atom-environment.js:811:28
at /Users/tech-a48/.atom/packages/my-package/package.json:1:1
This is the JSON file. Am I completely blind or am I missing something?
{
"name": "my-package",
"main": "./lib/my-package",
"version": "0.0.0",
"description": "A short description of your package",
"keywords": [
],
},
{
"repository": "https://github.com/atom/my-package",
"license": "MIT",
"engines": {
"atom": ">=1.0.0 <2.0.0"
},
"dependencies": {
}
}
Hi guy the problem is because the structure of JSON file is wrong.
Try it this.
{
"name": "my_package",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo"
},
"keywords": [],
"author": "ag_dubs",
"license": "ISC",
"repository": {
"type": "git",
"url": "https://github.com/someone/my_package.git"
},
"bugs": {
"url": "https://github.com/someone/my_package/issues"
},
"homepage": "https://github.com/someone/my_package"
}
This is going to be very difficult for us to troubleshoot, because your objects structure is incorrect. Here is a valid json object. (this may not be correct)
{
"name": "my-package",
"main": "./lib/my-package",
"version": "0.0.0",
"description": "A short description of your package",
"keywords": [],
"repository": "https://github.com/atom/my-package",
"license": "MIT",
"engines": {
"atom": ">=1.0.0 <2.0.0"
},
"dependencies": {}
}
Your code is showing incomplete json to begin with so I'm going to assume you mean to add { at the top. An object must be reproducable. The json you provided is not reproducable as shown below.
{
{
"name": "my-package",
"main": "./lib/my-package",
"version": "0.0.0",
"description": "A short description of your package",
"keywords": [
],
}, //this indicates you are ending the object that has the "name" property
//but then look below, now your next object doesn't start with a name property.
//If you truly want separate objects. You should name each of them, so they are properties of the parent.
{
"repository": "https://github.com/atom/my-package",
"license": "MIT",
"engines": {
"atom": ">=1.0.0 <2.0.0"
},
"dependencies": {
}
}
Try this, it may help:
{
"name": "my-package",
"main": "./lib/my-package",
"version": "0.0.0",
"description": "A short description of your package",
"keywords": []
},
{
"repository": "https://github.com/atom/my-package",
"license": "MIT",
"engines":
{
"atom": ">=1.0.0 <2.0.0"
}
},
{
"dependencies": {}
}
Related
I have a list of dictionaries (basically JSON Response of an endpoint)
I would need to Parse this 16000 lines of json objects and fitler the documents/objects which match criteria that
whose leaf element/field : statusInfo/status in not "UP" and of those filtered objects, just return "name" , "serviceUrl","status"
example :
"ADMIN-V1" "http://aws-ec2.aws.com:4435" "Warning"
I have been researching about JSONPath module , but there is no good documentation about it, and I could not find any easier way.
Any guidance is highly appreciated.
here is a snippet from long 16000 lines of JSON response.
[
{
"id": "9c108ec5",
"name": "USER-V2",
"managementUrl": "http://aws-ec2.aws.com:5784/",
"healthUrl": "http://aws-ec2.aws.com:5784/health",
"serviceUrl": "http://aws-ec2.aws.com:5784/",
"statusInfo": {
"status": "UP",
"timestamp": 1566663146681,
"details": {
"description": " Eureka Discovery Client",
"status": "UP"
}
},
"source": "discovery",
"metadata": {},
"info": {
"component": "user",
"description": "User REST Resource",
"version": "2.2.1",
"git": {
"commit": {
"time": "07/27/2018 # 15:06:55 CDT",
"id": "b2a1b37"
},
"branch": "refs/tags/v2.2.1"
}
}
},
{
"id": "1a381f20",
"name": "ADMIN-V1",
"managementUrl": "http://aws-ec2.aws.com:4435/",
"healthUrl": "http://aws-ec2.aws.com:4435/health",
"serviceUrl": "http://aws-ec2.aws.com:4435/",
"statusInfo": {
"status": "Warning",
"timestamp": 1566663146682,
"details": {
"description": "Spring Cloud Eureka Discovery Client",
"status": "Warning"
}
},
"source": "discovery",
"metadata": {},
"info": {
"description": "Exchange Admin REST Resource",
"api": {
"version": "1.2.1",
"name": "admin",
"link": "https://app.swaggerhub.com/apis/AWSExchange/admin/1.2.1"
},
"implementation": "admin",
"version": "1.1.0",
"git": {
"commit": {
"time": "01/04/2019 # 15:36:48 UTC",
"id": "39d5551"
},
"branch": "refs/tags/v1.1.0"
}
}
}
]
If your json file contains one big array, you'll want to stream that file in truncating out the array. Then use fromstream/1 to rebuild the objects and filtering them out as you go.
I don't have a representative file to test out the performance myself, but give this a try:
$ jq --stream -n 'fromstream(1|truncate_stream(inputs))
| select(.statusInfo.status != "UP")
| .name, .serviceUrl, .statusInfo.status
' input.json
I'm trying to create a template which does multiple vm's in Azure and then encrypts the disks, I've managed to get it working with 2 vm's about 3 hours ago, however when I do three of more vm's in the loop I get the following error:
"code": "DeploymentFailed",
"message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.",
"details": [
{
"code": "Conflict",
"message": "{\r\n \"error\": {\r\n \"code\": \"DeploymentActive\",\r\n \"message\": \"Unable to edit or replace deployment 'updatevm': previous deployment
from '12/29/2018 1:11:34 AM' is still active (expiration time is '1/5/2019 1:11:34 AM'). Please see https://aka.ms/arm-deploy for usage details.\"\r\n }\r\n}"
}
]
}
]
Is there a way of putting a pause so it waits for the updatevm extension to complete?
The section of code I have for the encryption is:
{
"name": "[concat(parameters('VMNames'),copyIndex(),'UpdateEncryptionSettings')]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('VMNames'),copyIndex(1))]"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[concat(parameters('_artifactsLocation'),'/nestedtemplates/encryptVm.json',parameters('_artifactsLocationSasToken'))]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"vmName": {
"value": "[concat(parameters('VMNames'), copyIndex(1))]"
},
"aadClientID": {
"value": "[parameters('aadClientID')]"
},
"aadClientSecret": {
"value": "[parameters('aadClientSecret')]"
},
"keyVaultName": {
"value": "[parameters('keyVaultName')]"
},
"keyVaultResourceGroup": {
"value": "[parameters('keyVaultResourceGroup')]"
},
"useExistingKek": {
"value": "[parameters('useExistingKek')]"
},
"keyEncryptionKeyURL": {
"value": "[parameters('keyEncryptionKeyURL')]"
},
"_artifactsLocation": {
"value": "[parameters('_artifactsLocation')]"
},
"_artifactsLocationSasToken": {
"value": "[parameters('_artifactsLocationSasToken')]"
}
}
}
},
make it depend on the previous extension, since you do not provide the exact code, its something like:
"dependsOn": [
"updatevm"
}
this didnt exactly work due to how the templates were structured, the answer was to use serial copy mode to only create one copy at a timeю
"copy": {
"name": "storagecopy",
"count": 4,
"mode": "serial",
"batchSize": 1
}
https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple#resource-iteration
I have different swagger files for multiple APIs, like swagger1.json for OpenStack API, swagger2.json for Users API etc and I was trying to merge these all swagger files in one single file using remote $ref method.
Here is swagger1.json file for OpenStack api
{
"stacks": {
"get": {
"tags": [
"openstack"
],
"summary": "Returns stacks from OpenStack",
"description": "Returns all stacks from the OpenStack based on tenantId.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"in": "query",
"type": "string",
"name": "tenantId",
"description": "search stacks for tenantId from OpenStack",
"required": false
}
],
"responses": {
"200": {
"description": "OK"
},
"400": {
"description": "Unknown Error"
},
"401": {
"description": "Unauthorized"
}
}
}
}
}
And this is the swagger-merge.json where I want to add multiple swagger doc file using remote reference.
{
"swagger": "2.0",
"info": {
"description": "something here",
"version": "v0.7.0",
"title": "The API Gateway",
"contact": {
"email": "dp#gmail.com"
}
},
"host": "localhost",
"port":"9191",
"basePath": "/api/openstack",
"tags": [
{
"name": "OpenStackApi",
"description": "Get stacks and running instance form OpenStack"
}
],
"schemes": [
"https"
],
"paths": {
"$ref": "./swagger1.json#/stacks"
}
}
This isn't working for me. I am not able to see API methods I have written inside swagger1.json file. I have upload swaggerUI output. Any idea about what I am doing wrong and how can I solve this issue?
You can't $ref the whole contents of paths, you can only refer individual path items:
"paths": {
"/stacks": { <--- endpoint path
"$ref": "./swagger1.json#/stacks"
}
}
For me not a single json string worked with the swagger editor.
Here is an example which i took from the page:
{
"swaggerVersion": "2.0",
"basePath": "http://localhost:8000/greetings",
"apis": [
{
"path": "/hello/{subject}",
"operations": [
{
"method": "GET",
"summary": "Greet our subject with hello!",
"type": "string",
"nickname": "helloSubject",
"parameters": [
{
"name": "subject",
"description": "The subject to be greeted.",
"required": true,
"type": "string",
"paramType": "path"
}
]
}
]
}
],
"models": {}
}
So current error for this, is:
✖ YAML Syntax Error
Missed comma between flow collection entries at line 2, column 14: "swagger: "2.0", ^
I don't know where did you take the base code for but that syntax seems to be totally wrong (at least for swagger 2), I recommend you to take a look to the official specification.
About the code you pasted, I refactorized it, try with this one:
{
"swagger": "2.0",
"host": "localhost:8000",
"basePath": "/greetings",
"info": {
"title": "Some title",
"version": "0.0.1"
},
"paths": {
"/hello/{subject}": {
"get": {
"summary": "Greet our subject with hello!",
"parameters": [{
"name": "subject",
"description": "The subject to be greeted.",
"required": true,
"type": "string",
"in": "path"
}],
"responses": {
"default": {
"description": "Some description",
"schema": {
"type": "string"
}
}
}
}
}
}
}
Even though the OP's syntax was wrong, this is for other people who are searching for an answer and their syntax is correct.
If you are getting the JSON data from the browser and you have a browser extension that formats and displays nicely the JSON data, it might cause trouble (because of the formatting) when pasting in Swagger Editor.
If that's the case, try disabling the extension or go incognito.
{
"name": "marvel/xmen",
"description": "Mutants saving the world for people who hate them",
"keywprds": ["mutant", "superhero", "bald", "guy"],
"homepage": "htp://marvel.com/mutants",
"time": "1963-09-01",
"license": "MIT",
"authors":
[
{
"name": "Stan Lee"
"email": "StanLee#gmail.com"
"homepage": "http://marvel.com",
"role": "engineer"
}
]
}
You are missing commas in the "authors" array. Should be as such:
{
"name": "marvel/xmen",
"description": "Mutants saving the world for people who hate them",
"keywprds": ["mutant", "superhero", "bald", "guy"],
"homepage": "htp://marvel.com/mutants",
"time": "1963-09-01",
"license": "MIT",
"authors":
[
{
"name": "Stan Lee",
"email": "StanLee#gmail.com",
"homepage": "http://marvel.com",
"role": "engineer"
}
]
}