英文:
What is the proper syntax of the following JSON string
问题
I need to extract data from MSACCES database in JSON object...
So I'm not quite sure about the right JSON string syntax.
Which one is correct:
{
"Continent": {
"Europe": {
"Countries":
{
"The Netherlands": {
"Cities": [
"Rotterdam",
"Hag",
"Amsterdam"
]
}
},
{
"Germany": {
"Cities": [
"Bon",
"Berlin"
]
}
}
}
}
}
or this one:
{
"Continent": {
"Europe": {
"Countries": [
{
"The Netherlands": {
"Cities": [
"Rotterdam",
"Hag",
"Amsterdam"
]
}
},
{
"Germany": {
"Cities": [
"Bon",
"Berlin"
]
}
}
]
}
}
}
I wonder between {"Countries":[{"The Net... or {"Countries":{"The Net...
英文:
I need to extract data from MSACCES database in JSON object...
So I'm not quite sure about the right JSON string syntax.
Which one is correct:
{
"Continent": {
"Europe": {
"Countries":
{
"The Netherlands": {
"Cities": [
"Rotterdam",
"Hag",
"Amsterdam"
]
}
},
{
"Germany": {
"Cities": [
"Bon",
"Berlin"
]
}
}
}
}
}
or this one:
{
"Continent": {
"Europe": {
"Countries": [
{
"The Netherlands": {
"Cities": [
"Rotterdam",
"Hag",
"Amsterdam"
]
}
},
{
"Germany": {
"Cities": [
"Bon",
"Berlin"
]
}
}
]
}
}
}
I wonder between {"Countries":[{"The Net... or {"Countries":{"The Net..
答案1
得分: 1
由于您拥有一个Country[]
数组,我建议将您的Country
键重命名为Countries
:
Countries: [{}, {}]
英文:
Since you are having an array of Country[]
, I would advice you to rename your Country
key by Countries
:
Countries: [{}, {}]
答案2
得分: 0
以下是翻译好的部分:
IMHO,最好的方法是保持关系
"Continens": {
"Continent": "Europe",
"Countries": [
{
"Country": "The Netherlands",
"Cities": [
"Rotterdam",
"Hag",
"Amsterdam"
]
},
{
"Country": "Germany",
"Cities": [
"Bon",
"Berlin"
]
}
]
}
}
classes(翻译成您的语言)
{
public Continens Continens { get; set; }
}
public class Continens
{
public string Continent { get; set; }
public List<Country> Countries { get; set; }
}
public class Country
{
public string Country { get; set; }
public List<string> Cities { get; set; }
}
英文:
IMHO, the best way is to keep relations
{
"Continens": {
"Continent": "Europe",
"Countries": [
{
"Country": "The Netherlands",
"Cities": [
"Rotterdam",
"Hag",
"Amsterdam"
]
},
{
"Country": "Germany",
"Cities": [
"Bon",
"Berlin"
]
}
]
}
}
classes (translate to your language)
public class World
{
public Continens Continens { get; set; }
}
public class Continens
{
public string Continent { get; set; }
public List<Country> Countries { get; set; }
}
public class Country
{
public string Country { get; set; }
public List<string> Cities { get; set; }
}
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论