Package ghidra.app.util.bin.format.golang.rtti

# 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.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final record`
  `JsonPatch.PatchLine`
  `static enum`
  `JsonPatch.PatchOp`
  `static final record`
  `JsonPatch.PatchSection`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JsonPatch(List<JsonPatch.PatchSection> sections)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getSectionCount()`
  `List<JsonPatch.PatchSection>`
  `getSections()`
  `static JsonPatch`
  `read(com.google.gson.JsonArray patchSectionElements)`
  Creates a new instance using the contents of the jsonarray.
  `static JsonPatch`
  `read(File patchFile)`
  Creates a new instance using the contents of the supplied file.
  `static JsonPatch`
  `read(String patchString)`
  Creates a new instance using the contents in the supplied string.
  `static JsonPatch`
  `read(ListIterator<String> lineIterator)`
  Creates a new instance using the contents of the supplied text lines.
  `com.google.gson.JsonArray`
  `toJson()`
  Converts this patch to a json array.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### JsonPatch

    public JsonPatch(List<JsonPatch.PatchSection> sections)

- ## 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.