What are good CLI tools for JSON?

后端 未结 8 1243
难免孤独
难免孤独 2021-01-30 00:45

General Problem

Though I may be diagnosing the root cause of an event, determining how many users it affected, or distilling timing logs in order to assess the perform

8条回答
  •  走了就别回头了
    2021-01-30 01:20

    Have a look at the f:json-document() from the FXSL 2.x library.

    Using this function it is extremely easy to incorporate JSon and use it just as... XML.

    For example, one can just write the following XPath expression:

    f:json-document($vstrParam)/Students/*[sex = 'Female']
    

    and get all children of Students with sex = 'Female'

    Here is the complete example:

    
     
    
     
    
     
    {
    
      "teacher":{
        "name":
          "Mr Borat",
        "age":
          "35",
        "Nationality":
          "Kazakhstan"
                 },
    
    
      "Class":{
        "Semester":
          "Summer",
        "Room":
          null,
        "Subject":
          "Politics",
        "Notes":
          "We're happy, you happy?"
               },
    
      "Students":
        {
          "Smith":
            {"First Name":"Mary","sex":"Female"},
          "Brown":
            {"First Name":"John","sex":"Male"},
          "Jackson":
            {"First Name":"Jackie","sex":"Female"}
        }
        ,
    
    
      "Grades":
    
        {
          "Test":
          [
            {"grade":"A","points":68,"grade":"B","points":25,"grade":"C","points":15},
    
            {"grade":"C","points":2, "grade":"B","points":29, "grade":"A","points":55},
    
            {"grade":"C","points":2, "grade":"A","points":72, "grade":"A","points":65}
           ]
        }
    
    
    }
     
    
     
        
    
     
    
    

    When the above transformation is applied on any XML document (ignored), the correct result is produced:

    
       Mary
       Female
    
    
       Jackie
       Female
    
    

提交回复
热议问题