Mam problem z pobieraniem pliku json, który próbuję utworzyć, aby użyć schematu json, który utworzyłem, aby można było użyć zarówno intellisense, jak i walidacja, aby zapewnić jsonowi, że muszę ręcznie zaciąć jest dobry. Nie jestem pewien, czy to mój schemat jest nieprawidłowy, czy też próbuję uzyskać VS2015, aby go użyć.Jak uzyskać schemat JSON do pracy w programie Visual Studio 2015 (Intellisense i sprawdzanie poprawności)
Na razie rzuciłem wszystkie pliki schematów do jednego pliku (wystąpiły problemy podczas próby podzielenia go).
{
"$schema": "http://json-schema.org/schema#",
"id": "http://savatronix.com/jsonschemas/losthaven1/MainSchemaV1.json",
"title": "Lost Haven Common JSON",
"description": "A schema for json types that will be common across many different object types. V1",
"definitions": {
"gameDateTime": {
"type": "object",
"properties": {
"year": {
"type": "integer",
"minimum": 0
},
"month": {
"type": "string",
"enum": [ "Nil", "Spring", "Summer", "Autumn", "Winter" ]
},
"weekday": {
"type": "string",
"enum": [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]
},
"day": {
"type": "integer",
"minimum": 0,
"maximum": 30
},
"hour": {
"type": "integer",
"minimum": 0,
"maximum": 23
},
"minute": {
"type": "integer",
"minimum": 0,
"maximum": 59
},
"second": {
"type": "integer",
"minimum": 0,
"maximum": 59
}
}
},
"characterAttributes": {
"type": "object",
"properties": {
"strength": {
"type": "integer",
"minimum": 0
},
"agility": {
"type": "integer",
"minimum": 0
},
"dexterity": {
"type": "integer",
"minimum": 0
},
"intelligence": {
"type": "integer",
"minimum": 0
},
"endurance": {
"type": "integer",
"minimum": 0
},
"charisma": {
"type": "integer",
"minimum": 0
},
"luck": {
"type": "integer",
"minimum": 0
}
}
},
"characterElements": {
"type": "object",
"properties": {
"earth": { "type": "integer" },
"wind": { "type": "integer" },
"fire": { "type": "integer" },
"water": { "type": "integer" },
"lightning": { "type": "integer" },
"light": { "type": "integer" },
"dark": { "type": "integer" }
}
},
"characterStatus": {
"type": "object",
"properties": {
"poison": { "type": "integer" },
"paralyze": { "type": "integer" },
"sleep": { "type": "integer" },
"fatigue": { "type": "integer" },
"charm": { "type": "integer" },
"confusion": { "type": "integer" }
}
},
"characterStats": {
"type": "object",
"properties": {
"attackPower": {
"type": "integer",
"minimum": 0
},
"block": {
"type": "integer",
"minimum": 0
},
"health": {
"type": "integer",
"minimum": 0
},
"defense": {
"type": "integer",
"minimum": 0
},
"evade": {
"type": "integer",
"minimum": 0
},
"attackSpeed": {
"type": "integer",
"minimum": 0
},
"parry": {
"type": "integer",
"minimum": 0
},
"stamina": {
"type": "integer",
"minimum": 0
},
"movementSpeedModifier": { "type": "integer" },
"elementalPower": { "$ref": "#/definitions/characterElements" },
"statusPower": { "$ref": "#/definitions/characterStatus" }
}
},
"attributesAndStatsContainer": {
"type": "object",
"properties": {
"attributes": { "$ref": "#/definitions/characterAttributes" },
"stats": { "$ref": "#/definitions/characterStats" }
}
},
"characterEquipmentState": {
"type": "object",
"properties": {
"weaponId": { "type": "string" },
"headgearId": { "type": "string" },
"chestId": { "type": "string" },
"legsId": { "type": "string" },
"bootsId": { "type": "string" },
"glovesId": { "type": "string" },
"firstAccessoryId": { "type": "string" },
"secondAccessoryId": { "type": "string" }
}
},
"baseObjectState": {
"type": "object",
"properties": {
"baseId": { "type": "string" },
"referenceId": { "type": "string" }
}
},
"characterState": {
"type": "object",
"allOf": [
{ "$ref": "#/definitions/baseObjectState" },
{
"properties": {
"characterName": { "type": "string" },
"characterSex": {
"type": "string",
"enum": [ "Unknown", "Male", "Female" ]
},
"race": {
"type": "string",
"enum": [ "Unknown", "Human", "Yokai" ]
},
"baseStats": { "$ref": "#/definitions/attributesAndStatsContainer" },
"currentHealth": {
"type": "integer",
"minimum": 0
},
"birthday": { "$ref": "#/definitions/gameDateTime" },
"equippedItems": { "$ref": "#/definitions/characterEquipmentState" }
}
}
]
},
"enemyStateObject": {
"type": "object",
"allOf": [
{ "$ref": "#/definitions/characterState" },
{
"properties": {
"isBoss": { "type": "boolean" }
}
}
]
},
"enemyState": {
"type": "object",
"properties": {
"enemies": {
"type": "array",
"items": { "$ref": "#/definitions/enemyStateObject" },
"minItems": 1
}
}
},
"NpcState": {
"type": "object",
"allOf": [
{ "$ref": "#/definitions/characterState" },
{
"properties": {
"backgroundInfo": { "type": "string" },
"history": { "type": "string" },
"personalityDescription": { "type": "string" },
"job": {
"type": "string",
"enum": [ "None" ]
},
"isRecruitable": { "type": "boolean" },
"isEligableSignificantOther": { "type": "boolean" },
"significantOtherId": { "type": "string" },
"wallet": {
"type": "integer",
"minimum": 0
},
"inventory": {
"type": "array",
"items": { "type": "string" }
}
}
}
]
}
}
}
Próbuję użyć definicji enemyState stworzyć obiekt, który zawiera szereg wrogów (robi to dlatego, że blog MSDN zaleca stosowanie $ schematu więc VS będzie automatycznie wykryć pożądany schemat).
"enemyState": {
"type": "object",
"properties": {
"enemies": {
"type": "array",
"items": { "$ref": "#/definitions/enemyStateObject" },
"minItems": 1
}
}
},
W moim Enemies.json Próbowałem:
{
"$schema": "../../../JsonSchemas/MainSchema.json#/definitions/enemyState"
}
że to "MSDN blog post" zalecany sposób to zrobić: Intellisense for JSON Schema in the JSON Editor
Próbowałem również pominąć to i skopiować łącze bezpośrednio do paska lokalizacji schematu w edytorze.
Podczas wpisywania części $ Schema, jest to poprawna lokalizacja, ponieważ część #/defintions/enemyState działa poprawnie.
Jednak to jest jego zasięg. Nie otrzymuję intellisense ani walidacji, gdy próbuję stworzyć rzeczywisty json. Próbowałem zamknąć i ponownie otworzyć plik, a także ponownie uruchomić studio graficzne.
Pożądanym efektem, jaki chciałbym uzyskać, jest uzyskanie intellisense i walidacji, dzięki czemu mogę stworzyć szereg obiektów stanu wroga (co jest definicją różnych wrogów w grze, którą robię, i zostaje odczytany i załadowany do Jedność) i zapewniają wymagane właściwości (nie zostały jeszcze utworzone w schemacie, rysunek, który dodaję wymagane właściwości, po tym, jak je uruchomię), a także upewniając się, że wszystko jest w zakresie i że to potwierdza Wiem, że nie ma błędów.
Każda pomoc tutaj będzie doceniona.
Wielkie dzięki!
nie jestem nawet widząc bar schematu wymyślić w wanilii VS2015 Update 3, było tam coś trzeba było zainstalować na nim jak VS2013? Można również spróbować spojrzeć na schematy tutaj http://schemastore.org/json/ – kornman00
Nie myśl, że zainstalowałem coś specjalnego. Jest to obraz pokazany w sekcji "Określ schemat w rozwijanym polu tekstowym" w łączu Intellisense For JSON Schema (po otwarciu pliku json). – TylerWStx