Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

154
Vistas
Is there a Java equivalent of Javascript's JSON.parse reviver function that I can use to transform a value during when parsing

I am looking for a way to transform a value during parse.

I have base64 encoded content inside a json formatted string with dynamic keys.

{
    "key0": "irrelevant",
    "key1": "VXNlbGVzcyBiYXNlNjQgY29udGVudA==",
    "key2": "QW5vdGhlciBVc2VsZXNzIGJhc2U2NCBjb250ZW50",
    "key3": {
        "key4": "b25lIG1vcmUgVXNlbGVzcyBiYXNlNjQgY29udGVudA==",
        "key5": "irrelevant",
        "key6": {
            "key7": "b25lIG1vcmUgdXNlbGVzcyBiYXNlNjQgc3RyaW5n",
            "key8": "dXNlbGVzcyBiYXNlNjQgc3RyaW5n",
            "key9": "TGFzdCB1c2VsZXNzIGJhc2U2NCBzdHJpbmcsIGJ1dCB0aGVyZSBjb3VsZCBiZSBtb3Jl"
        }
    }
}

I would like to replace the base64 content with a string and end up with something like this:

{
    "key0": "irrelevant",
    "key1": "replaced base64",
    "key2": "replaced base64",
    "key3": {
        "key4": "replaced base64",
        "key5": "irrelevant",
        "key6": {
            "key7": "replaced base64",
            "key8": "replaced base64",
            "key9": "replaced base64"
        }
    }
}

Javascript's JSON.parse method has the concept of a reviver function. Which I am aware that a "reviver" is a Javascript concept, however I am looking for something similar in Java. Here is an example of how it works on Javascript.

  1. https://stackoverflow.com/a/24374222/6076761
  2. https://stackoverflow.com/a/44911097

I am currently using Gson to parse the string to JsonElement.

NB: I do not have any information about the class type for this json string.

I know I could potentially parse the string to JsonObject and then possibly check for these strings recursively after.

However if someone knows of a way that I can do this during parse, please assist.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda