Parse local JSON file with jQuery and Javascript

前端 未结 2 1431
说谎
说谎 2021-01-18 02:38

I\'m trying to parse a JSON file located on my computer. I want to parse it. The JSON file has this structure:

{
  \"sites\": {
    \"site\": [
      {
              


        
相关标签:
2条回答
  • 2021-01-18 02:41

    I don't think you need to parse the json. It will automatically parse the json since you are using $.getJSON().

    0 讨论(0)
  • 2021-01-18 02:43

    getJSON will parse it for you.

    Just remove the var obj = $.parseJSON(json); line (since that will stringify the object and try to parse it as JSON (which it won't be)).

    0 讨论(0)
提交回复
热议问题