-1

JSON出力とjqueryに関連する質問があります。これはjsonデータですが、構文は非常に奇妙です:

{"ResC": {
"@attributes": {
  "ver": "1.1",
  "prod": "HAFAS 5.31.VBB.4.8.9",
  "lang": "DE"
},
"STBRes": {
  "@attributes": {"plan_version": "planid=1358257894-planid_adr=1336152870-planid_poi=1357822240-planid_ext=1343914901"},
  "JourneyList": {"STBJourney": [
      {
        "@attributes": {"trainId": "1628608644#30.01.13"},
        "MainStop": {"BasicStop": {
            "@attributes": {"index": "4"},
            "Station": {"@attributes": {
                "name": "S+U Westhafen (Berlin)",
                "x": "13342724",
                "y": "52536529",
                "type": "WGS84",
                "externalId": "9001201#86",
                "externalStationNr": "9001201"
              }},
            "Dep": {"Time": "30.01.13T21:26"}
          }},
        "JourneyAttributeList": {"JourneyAttribute": [
            {
              "@attributes": {
                "from": "4",
                "to": "17"
              },
              "Attribute": {
                "@attributes": {"type": "NAME"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "U9"
                }
              }
            },
            {
              "@attributes": {
                "from": "4",
                "to": "17"
              },
              "Attribute": {
                "@attributes": {
                  "type": "CATEGORY",
                  "code": "1"
                },
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "U"
                }
              }
            },
            {
              "@attributes": {
                "from": "4",
                "to": "17"
              },
              "Attribute": {
                "@attributes": {"type": "INTERNALCATEGORY"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "U"
                }
              }
            },
            {
              "@attributes": {
                "from": "4",
                "to": "17"
              },
              "Attribute": {
                "@attributes": {"type": "OPERATOR"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "BVG"
                }
              }
            },
            {
              "@attributes": {
                "from": "4",
                "to": "17"
              },
              "Attribute": {
                "@attributes": {"type": "NUMBER"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "U9"
                }
              }
            },
            {
              "@attributes": {
                "from": "4",
                "to": "17"
              },
              "Attribute": {
                "@attributes": {"type": "DIRECTION"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "S+U Rathaus Steglitz (Berlin)"
                }
              }
            },
            {
              "@attributes": {
                "from": "4",
                "to": "17"
              },
              "Attribute": {
                "@attributes": {"type": "DIRECTIONFLAG"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "1"
                }
              }
            },
            {
              "@attributes": {
                "from": "4",
                "to": "17"
              },
              "Attribute": {
                "@attributes": {"type": "DIRECTIONCODE"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "9062202"
                }
              }
            },
            {
              "@attributes": {
                "from": "0",
                "to": "17"
              },
              "Attribute": {
                "@attributes": {
                  "priority": "350",
                  "type": "NORMAL",
                  "code": "RA"
                },
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "Fahrradmitnahme möglich"
                }
              }
            },
            {
              "@attributes": {
                "from": "0",
                "to": "17"
              },
              "Attribute": {
                "@attributes": {
                  "priority": "1",
                  "type": "NORMAL",
                  "code": "bf"
                },
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "barrierefrei"
                }
              }
            }
          ]},
        "ServiceDaysList": {"ServiceDays": {
            "ServiceBits": "FFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
            "RegularServiceText": {"Text": "täglich"},
            "IrregularServiceText": {"Text": "nicht 30. Mär"}
          }}
      },
      {
        "@attributes": {
          "trainId": "3599408640#30.01.13",
          "journeyId": "42221"
        },
        "MainStop": {"BasicStop": {
            "@attributes": {"index": "15"},
            "Station": {"@attributes": {
                "name": "S+U Westhafen (Berlin)",
                "x": "13342724",
                "y": "52536529",
                "type": "WGS84",
                "externalId": "9001201#86",
                "externalStationNr": "9001201"
              }},
            "Dep": {
              "Time": "30.01.13T21:27",
              "Platform": {"Text": "2"}
            },
            "StopPrognosis": {"Dep": {
                "Time": "30.01.13T21:27",
                "Platform": {"Text": "2"}
              }}
          }},
        "JourneyAttributeList": {"JourneyAttribute": [
            {
              "@attributes": {
                "from": "15",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {"type": "NAME"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "S42"
                }
              }
            },
            {
              "@attributes": {
                "from": "15",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {
                  "type": "CATEGORY",
                  "code": "0"
                },
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "S"
                }
              }
            },
            {
              "@attributes": {
                "from": "15",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {"type": "INTERNALCATEGORY"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "S-6"
                }
              }
            },
            {
              "@attributes": {
                "from": "15",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {"type": "OPERATOR"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "DBS"
                }
              }
            },
            {
              "@attributes": {
                "from": "15",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {"type": "NUMBER"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "S42"
                }
              }
            },
            {
              "@attributes": {
                "from": "15",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {"type": "DIRECTION"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "Ringbahn S 42"
                }
              }
            },
            {
              "@attributes": {
                "from": "15",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {"type": "DIRECTIONFLAG"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "2"
                }
              }
            },
            {
              "@attributes": {
                "from": "15",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {"type": "DIRECTIONCODE"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "R000498"
                }
              }
            },
            {
              "@attributes": {
                "from": "0",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {
                  "priority": "350",
                  "type": "NORMAL",
                  "code": "FB"
                },
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "Fahrradmitnahme möglich"
                }
              }
            },
            {
              "@attributes": {
                "from": "0",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {
                  "priority": "1",
                  "type": "NORMAL",
                  "code": "ck"
                },
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "barrierefrei"
                }
              }
            }
          ]},
        "ServiceDaysList": {"ServiceDays": {
            "ServiceBits": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
            "RegularServiceText": {"Text": "täglich"}
          }}
      },
      {
        "@attributes": {
          "trainId": "3599408634#30.01.13",
          "journeyId": "42221"
        },
        "MainStop": {"BasicStop": {
            "@attributes": {"index": "42"},
            "Station": {"@attributes": {
                "name": "S+U Westhafen (Berlin)",
                "x": "13342724",
                "y": "52536529",
                "type": "WGS84",
                "externalId": "9001201#86",
                "externalStationNr": "9001201"
              }},
            "Dep": {
              "Time": "30.01.13T21:27",
              "Platform": {"Text": "2"}
            },
            "StopPrognosis": {"Dep": {
                "Time": "30.01.13T21:27",
                "Platform": {"Text": "2"}
              }}
          }},
        "JourneyAttributeList": {"JourneyAttribute": [
            {
              "@attributes": {
                "from": "42",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {"type": "NAME"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "S42"
                }
              }
            },
            {
              "@attributes": {
                "from": "42",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {
                  "type": "CATEGORY",
                  "code": "0"
                },
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "S"
                }
              }
            },
            {
              "@attributes": {
                "from": "42",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {"type": "INTERNALCATEGORY"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "S-6"
                }
              }
            },
            {
              "@attributes": {
                "from": "42",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {"type": "OPERATOR"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "DBS"
                }
              }
            },
            {
              "@attributes": {
                "from": "42",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {"type": "NUMBER"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "S42"
                }
              }
            },
            {
              "@attributes": {
                "from": "42",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {"type": "DIRECTION"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "Ringbahn S 42"
                }
              }
            },
            {
              "@attributes": {
                "from": "42",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {"type": "DIRECTIONFLAG"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "2"
                }
              }
            },
            {
              "@attributes": {
                "from": "42",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {"type": "DIRECTIONCODE"},
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "R000498"
                }
              }
            },
            {
              "@attributes": {
                "from": "0",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {
                  "priority": "350",
                  "type": "NORMAL",
                  "code": "FB"
                },
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "Fahrradmitnahme möglich"
                }
              }
            },
            {
              "@attributes": {
                "from": "0",
                "to": "54"
              },
              "Attribute": {
                "@attributes": {
                  "priority": "1",
                  "type": "NORMAL",
                  "code": "ck"
                },
                "AttributeVariant": {
                  "@attributes": {"type": "NORMAL"},
                  "Text": "barrierefrei"
                }
              }
            }
          ]},
        "ServiceDaysList": {"ServiceDays": {
            "ServiceBits": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
            "RegularServiceText": {"Text": "täglich"}
          }}
      }
    ]}
}
}}

属性および型として宣言されたエントリがいくつかあります。DIRECTIONたとえば、タイプを使用してエントリのテキストをクエリする方法は?

4

1 に答える 1

1

この構文、通常の JSON について奇妙なことは何もありません:

data["ResC"]["@attributes"]["ver"] // "1.1"

私が推測するいくつかの XML から生成されたので、プロパティ名は"@attributes".

于 2013-01-30T20:35:57.400 に答える