0
[
 {
  frame: {data,data}
  radiotap: {data,data}
  wlan: {data,data}
  wlan: {data,data}strong text
 }
]

This is a compressed example of a wireshark json I'm working with. When I loop through the json using Python3 it only returns the last wlan element and I need the first. How would I access the data in that element?

It also gets the second "wlan" element when I try direct access ie print(json[0][wlan]), this returns the second wlan element.

1 Answers1

1

Maybe you should not use duplicate keys.

Does JSON syntax allow duplicate keys in an object?

But still you can use JSONDecoder:

from json import JSONDecoder


def met(a):
    return a


json="""{
  "frame": {"a": 10},
  "radiotap": {"b": 10},
  "wlan": {"c": 10},
  "wlan": {"d": 10}
 }
 """


for i in JSONDecoder(object_pairs_hook=met).decode(json):
    print(i)
Camile
  • 107
  • 5