Get index of a key in json

前端 未结 6 542
北恋
北恋 2021-01-31 03:48

I have a json like so:

json = { \"key1\" : \"watevr1\", \"key2\" : \"watevr2\", \"key3\" : \"watevr3\" }

Now, I want to know the index of a key

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-31 04:35

    What you are after are numerical indexes in the way classic arrays work, however there is no such thing with json object/associative arrays.

    "key1", "key2" themeselves are the indexes and there is no numerical index associated with them. If you want to have such functionality you have to assiciate them yourself.

提交回复
热议问题