Class JsonPatch

java.lang.Object
ghidra.app.util.bin.format.golang.rtti.JsonPatch

public class JsonPatch extends Object
Represents a sequence of operations that describe how a json file has changed.

This implementation currently only supports reading jd (https://github.com/josephburnett/jd) native format diffs.

  • Constructor Details

  • Method Details

    • read

      public static JsonPatch read(String patchString) throws IOException
      Creates a new instance using the contents in the supplied string.
      Parameters:
      patchString - diff text
      Returns:
      new JsonPatch instance
      Throws:
      IOException - if error
    • read

      public static JsonPatch read(File patchFile) throws IOException
      Creates a new instance using the contents of the supplied file.
      Parameters:
      patchFile - path to file containing json diff
      Returns:
      new JsonPatch instance
      Throws:
      IOException - if error
    • read

      public static JsonPatch read(ListIterator<String> lineIterator) throws IOException
      Creates a new instance using the contents of the supplied text lines.
      Parameters:
      lineIterator - iterator that provides lines of text containing the json diff
      Returns:
      new JsonPatch instance
      Throws:
      IOException - if error
    • read

      public static JsonPatch read(com.google.gson.JsonArray patchSectionElements) throws IOException
      Creates a new instance using the contents of the jsonarray. Allows storing a json patch in a json document.
      Parameters:
      patchSectionElements - json array containing the json diff sections
      Returns:
      new JsonPatch instance
      Throws:
      IOException - if error
    • getSectionCount

      public int getSectionCount()
    • getSections

      public List<JsonPatch.PatchSection> getSections()
    • toJson

      public com.google.gson.JsonArray toJson()
      Converts this patch to a json array.
      Returns:
      json array with json encoded patch/diff elements.