X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=mc-core%2Fpackage%2Fencode_json.py;fp=mc-core%2Fpackage%2Fencode_json.py;h=c59d595d4534e8a6ea84a7775f5cdf9d75c174a6;hb=3d4b88135c1a1429d8cecb7380cfc2f8c67d04ef;hp=0000000000000000000000000000000000000000;hpb=79eb47c2cfd81b81e911e69b67b99c965990f9a2;p=ric-app%2Fmc.git diff --git a/mc-core/package/encode_json.py b/mc-core/package/encode_json.py new file mode 100755 index 0000000..c59d595 --- /dev/null +++ b/mc-core/package/encode_json.py @@ -0,0 +1,34 @@ +#! /usr/bin/env python3 +#---------------------------------------------------------------------------------- +# +# Copyright (c) 2021 AT&T Intellectual Property. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +#--------------------------------------------------------------------------------- + + +# Abstract: This will read a json file and generate it as an escaped string on +# standard out. Simple way of stuffing the config into a curl command. +# +# Date: 28 January 2021 +# Author: E. Scott Daniels +# --------------------------------------------------------------------------------- + +import json +import sys + +f = open( sys.argv[1] ) +j = json.load( f ) +qj = json.dumps( j ) +print( qj.replace( '"', '\\"' ) )