My scenario, I have a file that I read, manipulate the strings and write 
back. It's not JSON, just some html tag stuff, where I'm replacing a few 
strings and then rewriting the file.

If in the process I encounter a string e.g., "${abcd}", how can I avoid 
 finding "\${abcd}" when rewriting the file?  

On Wednesday, May 22, 2013 11:19:34 PM UTC+3, Westley Hennigh wrote:
>
> Ya, should be fine in this case. Parsing proper JSON seems to work fine 
> and it even errors properly on the malformed strings with "\$".
>
> In this case all that needs to happen is we replace the call to 
> `print_quoted` (a trivial function) with a json-aware version that handles 
> any oddities... and so far the only thing that's come up is "\$".
>
> On Wednesday, May 22, 2013 1:04:18 PM UTC-7, Stefan Karpinski wrote:
>>
>> Starting from the versions in Base it probably shouldn't be too awful. I 
>> might take a look.
>>
>>
>> On Wed, May 22, 2013 at 3:59 PM, Westley Hennigh <[email protected]> 
>> wrote:
>>
>>> Ok, thanks.
>>>
>>> I guess I'll work on that then.
>>>
>>>
>>> On Wednesday, May 22, 2013 12:47:30 PM UTC-7, Stefan Karpinski wrote:
>>>
>>>> Using Julia's escaping and unescaping for JSON is a bit of a dirty hack 
>>>> that mostly happens to work but isn't really right – as you're discovering 
>>>> here. Since Julia strings and JSON strings aren't the same, it probably 
>>>> makes the most sense to write escape and unescape routines specifically 
>>>> for 
>>>> JSON rather than abusing the ones in Base. These functions shouldn't go in 
>>>> Base since they're JSON-specific. Even though other languages like C and 
>>>> Java will have fairly similar escaping routines, these rules are never 
>>>> quite identical, so I think we just handle interop with various systems on 
>>>> a case-by-case basis. Fortunately, everybody seems to understand JSON 
>>>> these 
>>>> days.
>>>>  
>>>> On Wed, May 22, 2013 at 1:22 PM, Westley Hennigh <[email protected]> 
>>>> wrote:
>>>>
>>>>> JSON.jl uses `print_quoted` to escape strings used to build json 
>>>>> objects. This is great, but doesn't handle julia strings like "bla bla 
>>>>> \$expensive-bla". "\$" is not valid json.
>>>>>
>>>>> I don't think it makes sense to change `print_quoted` (to remove the 
>>>>> "\"). From the perspective of most julia code that would be the opposite 
>>>>> of 
>>>>> printing quoted.
>>>>>
>>>>> I also don't think this is a JSON.jl specific issue, I suspect that 
>>>>> the same problem will come up anywhere people send julia strings to other 
>>>>> languages.
>>>>>
>>>>> So maybe there needs to be a new method in Base? Or is there a 
>>>>> solution to this problem that I've overlooked?
>>>>>
>>>>
>>>>
>>

Reply via email to