0

I'm trying to replace string in a very big json File (30MB) so i try to automate this. Here is an example of what I have

"local_notifications": [
    {
      "is_enabled": false,
      "notification_type": "basic",
      "notification_title": "localised_strings.show_name_debug_lobbies",
      "notification_body": "localised_strings.show_desc_debug_lobbies",
      "schedule": {
        "schedule_type": "dynamic",
        "elapsed_time": [
          {
            "days": 0,
            "hours": 0,
            "minutes": 1
          }
        ]
      },
      "priority": 0,
      "priority_override": false,
      "id": "debug_notification"
    },

I would like to replace the notification title and body with his localised strings which are at the bottom at the file like this

"localised_strings": [
    {
      "text": "Debug lobbies",
      "id": "show_name_debug_lobbies"
    },
    {
      "text": "Debug lobbies 2",
      "id": "show_desc_debug_lobbies"
    }
 ]

I want to do this in python but i don't know how to do it can you help me ?

P.S. The only part of code I have is to decrypt the crypted file:

import argparse
from argparse import RawTextHelpFormatter

xor_key = [0x61, 0x23, 0x21, 0x73, 0x43, 0x30, 0x2c, 0x2e]

description = ('Decrypt or encrypt content_v1 of Fall Guys: Ultimate Knockout\n'
'content_v1 is usually found inside %UserProfile%\AppData\LocalLow\Mediatonic\FallGuys_client')

argument_parser = argparse.ArgumentParser(description=description, formatter_class=RawTextHelpFormatter)

argument_parser.add_argument('input_file', help='content_v1 or a valid JSON file')
argument_parser.add_argument('output_file')

arguments = argument_parser.parse_args()

content = bytearray()
content_idx = 0

try:
  with open(arguments.input_file, 'rb') as input_file:
    while (byte := input_file.read(1)):
      content += bytes([ord(byte) ^ xor_key[content_idx % (len(xor_key))]])
      content_idx += 1
except (IOError, OSError) as exception:
  print('Error: could not read input file')
  exit()

try:
  with open(arguments.output_file, 'wb') as output_file:
    output_file.write(content)
except (IOError, OSError) as exception:
  print('Error: could not create output file')
  exit()
0

1 Answer 1

1

Did you try to convert your Json into a dictionary? for instance using these resources: https://www.geeksforgeeks.org/convert-json-to-dictionary-in-python/

You convert to a dictionary, you edit the contents of the key you want, then save it back to Json if you need

Sign up to request clarification or add additional context in comments.

1 Comment

I will try ASAP and I come back, thanks for your answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.